Loading data

From Jstacs
Revision as of 09:29, 29 October 2008 by Grau (talk | contribs)
Jump to navigationJump to search

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:
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 );