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  -  [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

Reply via email to