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@lists.open-bio.org
http://lists.open-bio.org/mailman/listinfo/biojava-l

Reply via email to