I'm not sure what you're trying to do here - are you trying to represent your
string array of sequences as a RichSequenceIterator, or are you trying to
convert them into FASTA? I'll answer both anyway...:
To convert your String[] of sequences into a RichSequenceIterator you need to
create a new class that implements the RichSequenceIterator interface. You
would probably write something like this (which I have not checked or compiled
- so if it has bugs, sorry!):
public class MyDNASeqIterator implements RichSequenceIterator {
private final String[] sequences;
private final int counter;
public MyDNASeqIterator(String[] sequences) { this.sequences = sequences;
this.counter = 0; }
public hasNext() {
return this.counter <= this.sequences.length;
}
public Sequence nextSequence() { return nextRichSequence(); }
public BioEntry nextBioEntry() { return nextRichSequence(); }
public RichSequence nextRichSequence() {
String seqName = "MySeq"+this.counter;
return RichSequence.Tools.createRichSequence(seqName,
this.sequences[this.counter++], DNATools.getDNA());
}
}
You can then instantiate an object using MyDNASeqIterator's constructor to give
it your string array, and iterate over it to get corresponding RichSequence
instances.
To convert your sequences to FASTA, use the above iterator to generate
sequences to pass to FastaFormat in the same way that you would write a normal
FASTA file.
cheers,
Richard
On 6 Dec 2009, at 14:04, Oliver Stolpe wrote:
> Hello *,
>
> I have a set of sequences as strings in an array. I now want to turn them
> into an iterator over RichSequences in fasta-format. I read in the cookbook,
> but I dont get it. And looked up the examples in biojavax-doc. I tried much
> but I have no good starting point. No starting point at all. How do the
> RichSequenceBuilder work? What about the FastaFormat-thing?
> I thought about putting the sequences in a fast-file and then read the file.
> But there must be a much more straight-forward way!
>
> Thanks in advance for any hints,
> Oliver
>
>
> _______________________________________________
> Biojava-l mailing list - [email protected]
> http://lists.open-bio.org/mailman/listinfo/biojava-l
--
Richard Holland, BSc MBCS
Operations and Delivery Director, Eagle Genomics Ltd
T: +44 (0)1223 654481 ext 3 | E: [email protected]
http://www.eaglegenomics.com/
_______________________________________________
Biojava-l mailing list - [email protected]
http://lists.open-bio.org/mailman/listinfo/biojava-l