[Biojava-l] how to get properties of a Feature from a GenBank file
Mark Schreiber
markjschreiber at gmail.com
Fri Mar 28 01:55:38 UTC 2008
These are good points. Can we generify interfaces without breaking them?
Certainly the addition of generics to the biojavax packages would remove a
lot of nasty casting. Adding convenience methods would certainly also help
biojavax code does get a bit verbose. Again this would break interfaces
unless we put them in some kind of tools class.
These are certainly good points to remember for future designs (eg biojava2)
usability should be a test criteria as well. BioJavaX gives excellent ORM
with BioSQL and great capture of detail in it's parsers but the coding style
is a bit unwieldy. 2 out of 3 is not bad though : )
- Mark
On Thu, Mar 27, 2008 at 10:11 PM, Richard Holland <holland at ebi.ac.uk> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello,
>
> Your code for getting the Note named "gene" is correct. I agree, a
> shorthand way of doing this would be lovely, but doesn't currently
> exist. (Such a method would have to do the same thing internally
> anyway). If you'd like to write one and add it in then you'd be most
> welcome! :)
>
> At the time that the BioJavaX extensions were written compatibility with
> Java 1.4 was still required and so we could not make use of any new Java
> features that were introduced in Java 1.5. Set<Feature>, being an
> example of Generics, is one of these.
>
> Future versions of BioJava will require the user to install Java 1.6 or
> later and so we will be able to use these newer features in both new and
> existing code, depending on feasibility (for instance it is not always
> possible to convert older code to use Generics in a sensible manner, and
> it is not always possible to write Generics code that can interface
> sensibly with older non-Generics modules).
>
> cheers,
> Richard
>
>
>
> Martin Jones wrote:
> > Hi,
> >
> > I'm just getting started with BioJava so this may be a simple
> > question. I'm reading a RichSequence from a GenBank file and want to
> > get the gene name of each CDS feature. The following code gets hold
> > of the features I'm interested in
> >
> > for (Object o : mySeq.getFeatureSet()){
> > RichFeature f = (RichFeature) o;
> > if (f.getType().equals("CDS")){
> > //get gene name here
> > }
> > }
> >
> > but I'm not sure how best to get the gene name. The following seems to
> work:
> >
> > for (Object o2 : f.getNoteSet()){
> > Note n = (Note) o2;
> > if (n.getTerm().getName().equals("gene")){
> > System.out.println("gene name is " + n.getValue());
> > }
> > }
> >
> > but seems overly verbose - ideally I'd like to be able to pass the
> > Feature to another part of my program, but writing the above whenever
> > I want to get the name seems like overkill. Is there a shorter way -
> > something along the lines of
> >
> > String name = f.getNoteByName("gene").getValue();
> >
> > Thanks in advance for any help.
> >
> > PS one more question - is there a reason why e.g. getNoteSet returns
> > a Set rather than a Set<Feature>, which makes it necessary to do all
> > the type casts?
> >
> > Thanks,
> >
> > Martin
> > _______________________________________________
> > Biojava-l mailing list - Biojava-l at lists.open-bio.org
> > http://lists.open-bio.org/mailman/listinfo/biojava-l
> >
>
> - --
> Richard Holland (BioMart)
> EMBL EBI, Wellcome Trust Genome Campus,
> Hinxton, Cambridgeshire CB10 1SD, UK
> Tel. +44 (0)1223 494416
>
> http://www.biomart.org/
> http://www.biojava.org/
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2.2 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFH66sO4C5LeMEKA/QRAmq9AJ4qyMw4eGVYIMZjVf5jcADVRQmzpQCeOXej
> mak90aLUhSF60DrWeRtM8o0=
> =0EOE
> -----END PGP SIGNATURE-----
> _______________________________________________
> Biojava-l mailing list - Biojava-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-l
>
More information about the Biojava-l
mailing list