Perhaps might be good to also add this as a cookbook recipe on the wiki? Andreas
On Fri, Nov 16, 2012 at 2:03 AM, Tony Power <[email protected]> wrote: > This is what I really needed as suggested by Michael: > List features = sequence.getFeaturesByType("qualityScores"); > > Instead what I was doing: > List<FeatureInterface<AbstractSequence<NucleotideCompound>, > NucleotideCompound>> features = s.getFeaturesByType("qualityScores"); > > Thanks you all guys for your feedback, > Tony > > > On Thu, Nov 15, 2012 at 4:37 PM, Michael Heuer <[email protected]> wrote: > > > Hello Tony, > > > > This unit test shows how to access the qualities in a QualityFeature > > > > public void testCreateDNASequenceWithQualityScores() > > { > > DNASequence sequence = > > FastqTools.createDNASequenceWithQualityScores(builder.build()); > > assertNotNull(sequence); > > > > List features = sequence.getFeaturesByType("qualityScores"); > > assertNotNull(features); > > assertEquals(1, features.size()); > > QualityFeature qualityScores = (QualityFeature) features.get(0); > > assertEquals(sequence.getLength(), > > qualityScores.getQualities().size()); > > assertEquals(sequence.getLength(), > > qualityScores.getLocations().getLength()); > > } > > > > > > > http://code.open-bio.org/biojava-live/trunk/biojava3-sequencing/src/test/java/org/biojava3/sequencing/io/fastq/FastqToolsTest.java?revision=9583&root=biojava&view=markup > > > > michael > > > > > > On Thu, Nov 15, 2012 at 10:34 AM, Michael Heuer <[email protected]> > wrote: > > > Hello Tony, > > > > > > The javadoc here > > > > > > > > > http://www.biojava.org/docs/api/org/biojava3/sequencing/io/fastq/FastqTools.html#createDNASequenceWithQualityScores%28org.biojava3.sequencing.io.fastq.Fastq%29 > > > > > > says "The quality scores are stored in a QualityFeature with a type > > > "qualityScores" the same length as the sequence." > > > > > > QualityFeature has several different methods to access the quality > > > scores, List<Number> getQualities, Number getQualitiesAt(int index), > > > etc. > > > > > > > > > http://www.biojava.org/docs/api/org/biojava3/core/sequence/features/QualityFeature.html > > > > > > > > > Alternatively, it may be more efficient to not create DNASequence > > > objects, something like > > > > > > FastqReader fastqReader = new SangerFastqReader(); > > > InputSupplier inputSupplier = Files.newReaderSupplier(new > > File("sanger.fastq")); > > > > > > fastqReader.stream(inputSupplier, new StreamListener() > > > { > > > @Override > > > public void fastq(final Fastq fastq) > > > { > > > int size = fastq.getSequence().length(); > > > double[] qualityScores = FastqTools.qualityScores(fastq, new > > > double[size]); > > > .... > > > } > > > }); > > > > > > michael > > > > > > > > > On Thu, Nov 15, 2012 at 9:03 AM, Tony Power <[email protected]> wrote: > > >> Thanks for the feedback. > > >> So, from the example I provided, how would you print the quality > > features? > > >> > > >> > > >> On Thu, Nov 15, 2012 at 2:46 PM, Scooter Willis <[email protected]> > > wrote: > > >> > > >>> Tony > > >>> > > >>> The features get added as a named string to support any number of > > feature > > >>> types. If you look in the FastqTools code should be able to find the > > >>> string that is used to denote the quality score and then use the > > >>> corresponding get method to return the value. > > >>> > > >>> Scooter > > >>> > > >>> On 11/15/12 9:23 AM, "Tony Power" <[email protected]> wrote: > > >>> > > >>> >Sorry, the message went before I finish it. > > >>> > > > >>> >How can I access the qualities of each sequence? > > >>> > > > >>> >I am trying like this: > > >>> >List<FeatureInterface<AbstractSequence<NucleotideCompound>, > > >>> >NucleotideCompound>> features = > s.getFeaturesByType("qualityScores"); > > >>> >for (int i = 0; i < features.size(); i++){ > > >>> > System.out.println(": " + > features.get(i).toString()); > > >>> >} > > >>> > > > >>> >How can I access the qualities? > > >>> > > > >>> >Thanks for your help, > > >>> >Tony > > >>> > > > >>> > > > >>> >On Thu, Nov 15, 2012 at 2:15 PM, Tony Power <[email protected]> > > wrote: > > >>> > > > >>> >> Hi, > > >>> >> > > >>> >> I am trying to access to the qualities created with the example: > > >>> >> > > >>> >> FastqReader fastqReader = new SangerFastqReader(); > > >>> >> List<DNASequence> sequences = new LinkedList<DNASequence>(); > > >>> >> for (Fastq fastq : fastqReader.read(new File > > >>> >>< > > >>> > > http://www.google.com/search?hl=en&q=allinurl%3Afile+java.sun.com&btnI=I > > >>> >>%27m%20Feeling%20Lucky>("sanger.fastq"))){ > > >>> >> > > sequences.add(FastqTools.createDNASequenceWithQualityScores(fastq));} > > >>> >> > > >>> >> > > >>> >_______________________________________________ > > >>> >Biojava-l mailing list - [email protected] > > >>> >http://lists.open-bio.org/mailman/listinfo/biojava-l > > >>> > > >>> > > >> _______________________________________________ > > >> Biojava-l mailing list - [email protected] > > >> http://lists.open-bio.org/mailman/listinfo/biojava-l > > > _______________________________________________ > biojava-dev mailing list > [email protected] > http://lists.open-bio.org/mailman/listinfo/biojava-dev > -- ----------------------------------------------------------------------- Dr. Andreas Prlic Senior Scientist, RCSB PDB Protein Data Bank University of California, San Diego (+1) 858.246.0526 ----------------------------------------------------------------------- _______________________________________________ Biojava-l mailing list - [email protected] http://lists.open-bio.org/mailman/listinfo/biojava-l
