Loading data: Difference between revisions

From Jstacs
Jump to navigationJump to search
No edit summary
No edit summary
Line 5: Line 5:
//create a Sample using the alphabet from above
//create a Sample using the alphabet from above
Sample data = new Sample( container, new StringExtractor( new File("myfile.txt"), 100 )
Sample data = new Sample( container, new StringExtractor( new File("myfile.txt"), 100 ) );
</source>
</source>


Line 15: Line 15:
//create a Sample using the alphabet from above in FastA-format
//create a Sample using the alphabet from above in FastA-format
Sample data = new Sample( container, new StringExtractor( new File("myfile.txt"), 100, StringExtractor.FASTA )
Sample data = new Sample( container, new StringExtractor( new File("myfile.txt"), 100, StringExtractor.FASTA ) );
</source>
</source>



Revision as of 08:15, 29 October 2008

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
Sample data = new Sample( container, new StringExtractor( new File("myfile.txt"), 100 ) );


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
Sample data = new Sample( container, new StringExtractor( new File("myfile.txt"), 100, StringExtractor.FASTA ) );


Creating a Sample from a BioJava SequenceIterator:

//defining the ids, we want to obtain from NCBI Genbank:
Set<String> ids = new HashSet<String>();
ids.add( "NC_003070" );
ids.add( "NC_003071" );
		
GenbankRichSequenceDB db = new GenbankRichSequenceDB();
RichSequenceDB db2 = db.getRichSequences( ids );
//getting a SequenceIterator
SequenceIterator it = db2.sequenceIterator();
		
//conversion to Jstacs Sample
Sample data = BioJavaAdapter.sequenceIteratorToSample( it, null );