Loading data
From Jstacs
Jump to navigationJump to search
Most simple way for loading DNA-sequences from a FastA file:
Sample data = new DNASample( home+"myfile.fa" );
Loading DNA-sequences from a FastA file:
//create a DNA-alphabet
AlphabetContainer container = new AlphabetContainer( new DNAAlphabet() );
//create a Sample using the alphabet from above in FastA-format
data = new Sample( container, new SparseStringExtractor( home+"myfile.fa", StringExtractor.FASTA ));
Loading DNA-sequences from a plain text file:
//create a DNA-alphabet
AlphabetContainer container = new AlphabetContainer( new DNAAlphabet() );
//create a Sample using the alphabet from above
data = new Sample( container, new SparseStringExtractor( home+"myfile.txt" ));
Creating a Sample from a BioJava SequenceIterator:
//defining the ids, we want to obtain from NCBI Genbank:
GenbankRichSequenceDB db = new GenbankRichSequenceDB();
SimpleSequenceIterator it = new SimpleSequenceIterator(
db.getRichSequence( "NC_001284.2" ),
db.getRichSequence( "NC_000932.1" )
);
//conversion to Jstacs Sample
Sample data = BioJavaAdapter.sequenceIteratorToSample( it, null );