Converting from Sequence<AminoAcidCompound> to ProteinSequence in BioJava 4
1
0
Entering edit mode
9.3 years ago
jstalker • 0

Hi there,

I'm hoping this is a dreadfully silly question and I'm just missing something fundamental in the JavaDocs because I can't seem to find a good example elsewhere.

Basically I'm working on a sequence validation project where I'm using the TranscriptionEngine class to translate all 6 frames, so I'm left with a map of Frame and Sequence<AminoAcidCompound> objects.

I can't, for the life of me, find the right was to convert from Sequence<AminoAcidCompound> to ProteinSequence

It's a general question really. Looking at the constructors for DNA, RNA, and ProteinSequence classes, they want SequenceReader or ProxySequenceReader instances.

Does this mean I need to construct an ArrayListSequenceReader from my Sequence<C> objects just to create the wrapper?

I have to be missing something.

Thanks!

Code below

​DNASequence dna = *readDNAFasta*(inputFasta);
Sequence<NucleotideCompound> subset = dna.getSubSequence(10, dna.getLength());

SequenceReader<NucleotideCompound> reader = **new **ArrayListSequenceReader<>(subset.getAsList(), subset.getCompoundSet());
DNASequence dnaFromSubset = **new **DNASequence(reader);

Obviously this is a contrived example. But it illustrates my point. What's the proper way to convert from a Sequence<NucleotideCompound> to a DNASequence object? I was hoping there was a simple wrapper, but there's nothing obvious.

biojava • 1.6k views
ADD COMMENT
0
Entering edit mode
9.3 years ago
andreas.prlic ▴ 290

a simple one-liner could be:

DNASequence newS = new DNASequence(subset.getSequenceAsString());
ADD COMMENT

Login before adding your answer.

Traffic: 2145 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6