[Biojava-l] Reading Fasta file problem (new to biojava)
Richard Holland
holland at eaglegenomics.com
Wed Dec 16 11:22:31 UTC 2009
You're almost right already - the sample code would be this:
BufferedReader br = new BufferedReader(new FileReader(args[0]));
Namespace ns = RichObjectFactory.getDefaultNamespace();
RichSequenceIterator iterator = RichSequence.IOTools.readFastaProtein(br,ns);
(No need to cast it - it's already a RichSequenceIterator).
The namespace is a hangover from the object model being based on BioSQL, where all sequences belong to a namespace. If you don't care about namespaces (which is highly likely if you're not persisting to BioSQL) then a default one is provided to use as a placeholder, as shown above.
cheers,
Richard
On 16 Dec 2009, at 09:10, Chris Cole wrote:
> [ repost as the first attempt never got through ]
>
> Hi,
>
> I'm new to biojava and relatively new to Java, but not new to progamming in general (perl and C).
>
> As a quick exercise I wanted to be able to read in a Fasta file, but this code here (Solution 2):
> http://biojava.org/wiki/BioJava:Cookbook:SeqIO:ReadFasta
>
> Has deprecated warnings for SeqIOTools and fileToBioJava(). The code currently works, but what's the non-deprecated way of going about it?
>
> I can see from Javadoc that RichSequence.IOTools from org.biojavax.bio.seq is now the recommended class, but how does one implement it?
>
> I've tried this, but readFastaProtein() requires a namespace, which I've no idea what that means.
> BufferedReader br = new BufferedReader(new FileReader(args[0]));
> RichSequenceIterator iter = (RichSequenceIterator)RichSequence.IOTools.readFastaProtein(br);
>
> All pointers appreciated.
> Cheers,
> Chris
> _______________________________________________
> Biojava-l mailing list - Biojava-l at lists.open-bio.org
> 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: holland at eaglegenomics.com
http://www.eaglegenomics.com/
More information about the Biojava-l
mailing list