[Biojava-l] Biojava-l Digest, Vol 101, Issue 14

Khalil El Mazouari khalil.elmazouari at gmail.com
Thu Jun 30 17:59:43 UTC 2011


Hi Hedwig

try this:

      RichFeature richFeature = RichFeature.Tools.makeEmptyFeature();
      RichLocation richLocation = new SimpleRichLocation(
          new SimplePosition(start), new SimplePosition(end), rank, RichLocation.Strand.POSITIVE_STRAND);
      richFeature.setLocation(richLocation);
	richFeature.setType("misc_feat"); // or get it from RichObjectFactory.
      richSequence.getFeatureSet().add(richFeature);

Regards,

khalil

On 30 Jun 2011, at 18:00, biojava-l-request at lists.open-bio.org wrote:

> Send Biojava-l mailing list submissions to
> 	biojava-l at lists.open-bio.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://lists.open-bio.org/mailman/listinfo/biojava-l
> or, via email, send a message with subject or body 'help' to
> 	biojava-l-request at lists.open-bio.org
> 
> You can reach the person managing the list at
> 	biojava-l-owner at lists.open-bio.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Biojava-l digest..."
> 
> 
> Today's Topics:
> 
>   1. Re: make feature to create embl or genbank file (Hedwig Kurka)
>   2. Re: make feature to create embl or genbank file (Hedwig Kurka)
>   3. Re: make feature to create embl or genbank file (Richard Holland)
>   4. Re: make feature to create embl or genbank file (George Waldon)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Thu, 30 Jun 2011 10:31:47 +0200
> From: Hedwig Kurka <kurka at mikro.biologie.tu-muenchen.de>
> Subject: Re: [Biojava-l] make feature to create embl or genbank file
> To: George Waldon <gwaldon at geneinfinity.org>,
> 	biojava-l at lists.open-bio.org
> Message-ID: <4E0C3473.7070406 at mikro.biologie.tu-muenchen.de>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> Hi George,
> 
> Thank you for your answer.
> I have some questions. Maybe very stupid, but I don't know how to get
> RichLocation objects.
> RichLocation loc = (RichLocation) new RangeLocation(start, stop);
> That doesn't work.
> And where does the programm know, that the feature lies on the plus or
> the minus strand?
> 
> Regards,
> Hedwig
> 
> Am 29.06.2011 17:39, schrieb George Waldon:
>> Hi Hedwig,
>> 
>> The problem holds with StrandedFeature. The strandeness of a feature
>> is the transdeness of its location. StrandedFeature should be
>> eliminated from bj1. Use biojavaX instead, something like this, once
>> you have created a RichLocation on the appropriate strand:
>> 
>> public Feature.Template getFeatureTemplate(RichSequence
>> parent,RichLocation loc) {
>>        RichFeature.Template templ = new RichFeature.Template();
>>        RichAnnotation rans = new SimpleRichAnnotation();
>>    templ.annotation = rans;
>>        templ.sourceTerm = // find an appropriate term
>>        templ.typeTerm =
>> RichObjectFactory.getDefaultOntology().getOrCreateTerm("CDS");
>>        templ.featureRelationshipSet = new TreeSet();
>>        templ.rankedCrossRefs = new TreeSet();
>>        templ.location = loc;
>> 
>>        // add notes if any you'd like
>> 
>>        return templ;
>> }
>> 
>> That should make it into the output file.
>> 
>> Regards,
>> George
>> 
>> 
>> Quoting Hedwig Kurka <kurka at mikro.biologie.tu-muenchen.de>:
>> 
>>> Hello all,
>>> 
>>> I have a problem concerning creating EMBL or Genbank files.
>>> Below is a fragment of my code and an example of how the EMBL file looks
>>> like.
>>> 
>>>       String name = "test genome";
>>>       String seqString = pFasta.getSequence(1, pFasta.getLength());
>>>       Sequence seq = DNATools.createDNASequence(seqString, name);
>>>       Alphabet dna =  AlphabetManager.alphabetForName("DNA");
>>>       RichSequence rs =
>>> Tools.createRichSequence(RichObjectFactory.getDefaultNamespace(), name,
>>> seqString, dna);
>>>       Set<Feature> rfeatSet = new HashSet<Feature>();
>>>       StrandedFeature.Template t = new StrandedFeature.Template();
>>>       for(int i=0; i<annotierten.size(); i++){
>>>                   int start = (int) Math.abs(anno.get(i).getStart());
>>>                   int stop = (int) Math.abs(anno.get(i).getStop());
>>>                   t.type = "CDS";
>>>                   if(start < stop){
>>>                       t.location = new RangeLocation(start, stop);
>>>                       t.strand = StrandedFeature.POSITIVE;
>>>                   }
>>>                   if(start > stop){
>>>                       t.location = new RangeLocation(stop, start);
>>>                       t.strand = StrandedFeature.NEGATIVE;
>>>                   }
>>>                   Feature f = seq.createFeature(t);
>>>                   RichFeature rf = RichFeature.Tools.enrich(f);
>>>                   rfeatSet.add(rf);
>>>       }
>>>       rs.setFeatureSet(rfeatSet);
>>>       rs = RichSequence.Tools.enrich(rs);
>>>       RichSequence.IOTools.writeEMBL(output, rs,
>>> RichObjectFactory.getDefaultNamespace());
>>> 
>>> EMBL file:
>>> FT   any             1889536..1890903
>>> FT   any             134636..136987
>>> FT   any             3727110..3727625
>>> FT   any             2812636..2813517
>>> FT   any             580648..581643
>>> FT   any             2330962..2331921
>>> FT   any             1012371..1013513
>>> FT   any             1260854..1261720
>>> FT   any             1602858..1603706
>>> FT   any             4108079..4108999
>>> FT   any             346637..347731
>>> FT   any             4073395..4074549
>>> 
>>> I wonder where the information of plus and minus strand is, why is there
>>> "any" in the file and not "CDS" and so on.
>>> 
>>> As tutorial I found that:
>>> http://www.biojava.org/wiki/BioJava:Cookbook:Locations:Feature. Is there
>>> another one?
>>> 
>>> Thank you for your help!
>>> 
>>> And any help is appreciated,
>>> 
>>> Hedwig
>>> 
>>> _______________________________________________
>>> Biojava-l mailing list  -  Biojava-l at lists.open-bio.org
>>> http://lists.open-bio.org/mailman/listinfo/biojava-l
>>> 
>> 
>> 
>> 
>> 
>> 
> 
> 
> 
> 
> ------------------------------
> 
> Message: 2
> Date: Thu, 30 Jun 2011 11:02:49 +0200
> From: Hedwig Kurka <kurka at mikro.biologie.tu-muenchen.de>
> Subject: Re: [Biojava-l] make feature to create embl or genbank file
> To: Richard Holland <holland at eaglegenomics.com>,
> 	biojava-l at lists.open-bio.org
> Message-ID: <4E0C3BB9.2030601 at mikro.biologie.tu-muenchen.de>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> I already built the set<RichFeature> and populated it.
> Now I want to give it the RichSequence. But when I do that in that line:
> 
> rs.setRichFeatureSet(rfeatSet);
> 
> It says, that it needs a Set<Feature>
> 
> Regards,
> Hedwig
> 
>> I'm not sure what you're trying to do - if you want to build a Set, you can just use the standard Java Collections API to create and populate a Set?
>> 
>> cheers,
>> Richard
>> 
>> On 30 Jun 2011, at 09:12, Hedwig Kurka wrote:
>> 
>> 
>>> Hi Richard,
>>> 
>>> Thank you for your answer.
>>> If I create RichFeature objects, then I have to do conversions in that line:
>>> RichFeature f = (RichFeature) seq.createFeature(t);
>>> and then I have in that line:
>>> rs.setRichFeatureSet(rfeatSet);
>>> the problem, that I have a Set<RichFeature> and not Set<Feature>, but I
>>> didn't find a method builds a Set containing RichFeature objects on a
>>> RichSequence. Is there one?
>>> 
>>> 
>>> 
>>>> The conversion from Feature to RichFeature does its best but is not
>>>> ideal. As you already have a RichSequence object to work with then you
>>>> would be better creating native RichFeature objects instead of doing
>>>> conversions.
>>>> 
>>>> Richard Holland
>>>> Eagle Genomics Ltd
>>>> Sent from my HTC
>>>> 
>>>> 
>>>> 
>>>> 
>>> 
>> --
>> 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/
>> 
>> 
>> 
>> 
> 
> 
> 
> ------------------------------
> 
> Message: 3
> Date: Thu, 30 Jun 2011 10:36:12 +0100
> From: Richard Holland <holland at eaglegenomics.com>
> Subject: Re: [Biojava-l] make feature to create embl or genbank file
> To: Hedwig Kurka <kurka at mikro.biologie.tu-muenchen.de>
> Cc: biojava-l at lists.open-bio.org
> Message-ID: <285A2F4C-9C8E-4300-A48B-E31E95601570 at eaglegenomics.com>
> Content-Type: text/plain; charset=us-ascii
> 
> There is a coding problem in ThinRichSequence (from which SimpleRichSequence and others extend) that allow only Set<Feature> as input, but require the Feature objects to actually be RichFeature objects. This was for a number of reasons that probably seemed good at the time but I have now forgotten what they were. The workaround is to declare your set as a Set<Feature> but populate it with RichFeature objects (as RichFeature extends Feature and so the Set will still accept them).
> 
> The code is being phased out in favour of the new BJ3 model so it is unlikely to be fixed, but hopefully this workaround solves your particular case.
> 
> cheers,
> Richard
> 
> On 30 Jun 2011, at 10:02, Hedwig Kurka wrote:
> 
>> I already built the set<RichFeature> and populated it.
>> Now I want to give it the RichSequence. But when I do that in that line:
>> 
>> rs.setRichFeatureSet(rfeatSet);
>> 
>> It says, that it needs a Set<Feature>
>> 
>> Regards,
>> Hedwig
>> 
>>> I'm not sure what you're trying to do - if you want to build a Set, you can just use the standard Java Collections API to create and populate a Set?
>>> 
>>> cheers,
>>> Richard
>>> 
>>> On 30 Jun 2011, at 09:12, Hedwig Kurka wrote:
>>> 
>>> 
>>>> Hi Richard,
>>>> 
>>>> Thank you for your answer.
>>>> If I create RichFeature objects, then I have to do conversions in that line:
>>>> RichFeature f = (RichFeature) seq.createFeature(t);
>>>> and then I have in that line:
>>>> rs.setRichFeatureSet(rfeatSet);
>>>> the problem, that I have a Set<RichFeature> and not Set<Feature>, but I
>>>> didn't find a method builds a Set containing RichFeature objects on a
>>>> RichSequence. Is there one?
>>>> 
>>>> 
>>>> 
>>>>> The conversion from Feature to RichFeature does its best but is not
>>>>> ideal. As you already have a RichSequence object to work with then you
>>>>> would be better creating native RichFeature objects instead of doing
>>>>> conversions.
>>>>> 
>>>>> Richard Holland
>>>>> Eagle Genomics Ltd
>>>>> Sent from my HTC
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>> --
>>> 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/
>>> 
>>> 
>>> 
>>> 
>> 
> 
> --
> 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/
> 
> 
> 
> 
> ------------------------------
> 
> Message: 4
> Date: Thu, 30 Jun 2011 10:24:23 -0500
> From: George Waldon <gwaldon at geneinfinity.org>
> Subject: Re: [Biojava-l] make feature to create embl or genbank file
> To: Hedwig Kurka <kurka at mikro.biologie.tu-muenchen.de>
> Cc: "biojava-l at lists.open-bio.org" <biojava-l at lists.open-bio.org>
> Message-ID: <20110630102423.185442z4cl0wn7eo at gator1273.hostgator.com>
> Content-Type: text/plain; charset=ISO-8859-1; DelSp="Yes";
> 	format="flowed"
> 
> No stupid question here, only bad answer. Hope this one is good:
> 
> http://www.biojava.org/wiki/BioJava:BioJavaXDocs#Working_with_RichLocation_objects.
> 
> - George
> 
> Quoting Hedwig Kurka <kurka at mikro.biologie.tu-muenchen.de>:
> 
>> Hi George,
>> 
>> Thank you for your answer.
>> I have some questions. Maybe very stupid, but I don't know how to get
>> RichLocation objects.
>> RichLocation loc = (RichLocation) new RangeLocation(start, stop);
>> That doesn't work.
> 
> 
> 
> 
> 
> 
> 
> ------------------------------
> 
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-l
> 
> 
> End of Biojava-l Digest, Vol 101, Issue 14
> ******************************************





More information about the Biojava-l mailing list