Loading data: Difference between revisions
From Jstacs
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
'''Loading DNA-sequences from a plain text file:''' | '''Loading DNA-sequences from a plain text file:''' | ||
<source lang=" | <source lang="java5"> | ||
//create a DNA-alphabet | //create a DNA-alphabet | ||
AlphabetContainer container = new AlphabetContainer( new DNAAlphabet() ); | AlphabetContainer container = new AlphabetContainer( new DNAAlphabet() ); | ||
Line 10: | Line 10: | ||
'''Loading DNA-sequences from a FastA file:''' | '''Loading DNA-sequences from a FastA file:''' | ||
<source lang=" | <source lang="java5"> | ||
//create a DNA-alphabet | //create a DNA-alphabet | ||
AlphabetContainer container = new AlphabetContainer( new DNAAlphabet() ); | AlphabetContainer container = new AlphabetContainer( new DNAAlphabet() ); | ||
Line 20: | Line 20: | ||
'''Creating a Sample from a BioJava SequenceIterator:''' | '''Creating a Sample from a BioJava SequenceIterator:''' | ||
<source lang=" | <source lang="java5"> | ||
//defining the ids, we want to obtain from NCBI Genbank: | //defining the ids, we want to obtain from NCBI Genbank: | ||
Set<String> ids = new HashSet<String>(); | Set<String> ids = new HashSet<String>(); |
Revision as of 12:21, 7 September 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 );