[Biojava-l] Re: [BioSQL-l] How to add a feature?

Simon Foote simon.foote at nrc-cnrc.gc.ca
Thu Jun 2 09:34:30 EDT 2005


Hi Martina,

To add a feature to a sequence stored in a  BioSQL database, all you 
have to do is retrieve the sequence and then add a feature to it.  The 
following simplified code shows you the steps:

// Retrieve the sequence from BioSQLSequenceDB
Sequence seq = bsd.getSequence(id);
// Create new stranded feature
StrandedFeature.Template templ = new StrandedFeature.Template();
templ.location = ...
templ.strand = ...
templ.type = ...
templ.source = ...
templ.annotation = [A created SimpleAnnotation object]
// Add feature to sequence
seq.createFeature(templ);
// Note: adding the feature like this will automatically persist the 
feature, so you don't have to worry about doing that.

Cheers,
Simon Foote

-- 
Bioinformatics Programmer
Pathogen Genomics
Institute for Biological Sciences
National Research Council of Canada
[T] 613-990-0561  [F] 613-952-9092
simon.foote at nrc-cnrc.gc.ca


Martina wrote:

> Thanks Marc,
> but I don't know how to make a feature persistent in Biojava. Maybe 
> someone from the bioJava list can help me?
>
> Martina
>
> Marc Logghe wrote:
>
>> Hi Martina,
>> I don't know how it goes in BioJava but in BioPerl the flow looks like
>> this:
>> 1) create your feature
>> 2) make it persistent
>> 3) add it to your (persistent) sequence object
>> 4) store the sequence object in the databse
>> 5) commit if necessary
>>
>> HTH,
>> Marc
>>
>>
>>> I'm wondering how to add a feature to a given sequence?
>>> I know, I can use createFeature, but that changes nothing in the 
>>> database, that does addSequence. So is the proper way to retrieve 
>>> the seq., get all its features, copy it to new seq and add a 
>>> feature, delete the seq in the database and store the new one?
>>> There must be a simpler way? BioJava In Anger is rather sparse on 
>>> things like that, I could do with a lot more examples ..
>>>
>>> Martina
>>> _______________________________________________
>>> BioSQL-l mailing list
>>> BioSQL-l at open-bio.org
>>> http://open-bio.org/mailman/listinfo/biosql-l
>>
>>
>>
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l at biojava.org
> http://biojava.org/mailman/listinfo/biojava-l




More information about the BioSQL-l mailing list