Loading data: Difference between revisions

From Jstacs
Jump to navigationJump to search
(New page: '''Loading DNA-sequences from a plain text file:''' <source lang="java"> //create a DNA-alphabet AlphabetContainer container = new AlphabetContainer( new DNAAlphabet() ); //create a Sam...)
 
No edit summary
Line 8: Line 8:
</source>
</source>


<hr />
 
'''Loading DNA-sequences from a FastA file:'''
'''Loading DNA-sequences from a FastA file:'''
<source lang="java">
<source lang="java">
Line 18: Line 18:
</source>
</source>


<hr />
 
'''Creating a Sample from a BioJava SequenceIterator:'''
'''Creating a Sample from a BioJava SequenceIterator:'''
<source lang="java">
<source lang="java">

Revision as of 12:13, 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 );