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:'''
'''Most simple way for loading DNA-sequences from a FastA file:'''
<source lang="java5">
<source lang="java5">
//create a DNA-alphabet
Sample data = new DNASample( home+"myfile.fa" );
</source>
 
'''Loading DNA-sequences from a FastA file:'''
<source lang="java5">//create a DNA-alphabet
AlphabetContainer container = new AlphabetContainer( new DNAAlphabet() );
AlphabetContainer container = new AlphabetContainer( new DNAAlphabet() );
 
//create a Sample using the alphabet from above
//create a Sample using the alphabet from above in FastA-format
Sample data = new Sample( container, new StringExtractor( new File("myfile.txt"), 100 ) );
data = new Sample( container, new SparseStringExtractor( home+"myfile.fa", StringExtractor.FASTA ));
</source>
</source>


 
'''Loading DNA-sequences from a plain text file:'''
'''Loading DNA-sequences from a FastA file:'''
<source lang="java5">
<source lang="java5">
//create a DNA-alphabet
//create a DNA-alphabet
AlphabetContainer container = new AlphabetContainer( new DNAAlphabet() );
AlphabetContainer container = new AlphabetContainer( new DNAAlphabet() );
 
//create a Sample using the alphabet from above in FastA-format
//create a Sample using the alphabet from above
Sample data = new Sample( container, new StringExtractor( new File("myfile.txt"), 100, StringExtractor.FASTA ) );
data = new Sample( container, new SparseStringExtractor( home+"myfile.txt" ));
</source>
</source>



Latest revision as of 13:46, 2 December 2009

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