From indapa at gmail.com Tue Sep 6 13:31:36 2005 From: indapa at gmail.com (Amit Indap) Date: Tue Sep 6 13:48:44 2005 Subject: [BioSQL-l] storing features to the database Message-ID: <3cfaa4040509061031558c2a32@mail.gmail.com> Hi, I have the following code that attempts to add a seq feature to a sequence in my biosql database: my $adp = $dbadp->get_object_adaptor("Bio::SeqI"); my $seq = Bio::Seq->new(-accession => $acc, --namespace =>$namespace, -version = $ver); my $dbseq = $adp->find_by_unique_key($seq); my $feat = new Bio::SeqFeature::Generic(-primary_tag = >$primary_tag, -strand => 1, -start => 100, -end => 10000, -source_tag => 'blat' ); $dbseq->add_SeqFeature($feat); $dbseq->store; - I had ~20,000 sequences I added features to. Yet when I run another script that lists features of sequences, these records come up with no features! I'm not really sure what's going on. I made sure my namespace and other parameters were correct. Maybe I should try and just run the script again. Thanks, Amit Indap Cornell University From indapa at gmail.com Wed Sep 7 11:42:56 2005 From: indapa at gmail.com (Amit Indap) Date: Wed Sep 7 11:59:30 2005 Subject: [BioSQL-l] having trouble creating persistent features Message-ID: <3cfaa4040509070842344db77e@mail.gmail.com> Hi, I'm still have some trouble adding features to sequences stored in my biosql database. After reading through the code of some test scripts that came with bioperl-db and googling around this is my understanding: 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 In my code snippet it below I retriveve the sequence from the biosql db, add a persistent feature, and store it. Then I re-retrieve the same sequence and see if my new sequence features show up. But when I run another script, after the one below finishes, to list features my newly added features do not show up. I am at a loss on what to do next. Does the store() command commit changes to the underly biosql database or am I missing another step? Thanks for your help, Amit my $dbadp = Bio::DB::BioDB->new( -database => 'biosql', -user => 'amit', -dbname => 'mydb', -pass => 'foobar, -host => 'localhost', -driver => 'mysql', ); . . . my $adp = $dbadp->get_object_adaptor("Bio::SeqI"); my $seq = Bio::Seq->new(-accession_number => $acc, -namespace => $namespace, -version => $ver); my $dbseq = $adp->find_by_unique_key($seq); warn $dbseq->accession_number(), " not found in database $namespace" unless $dbseq; my $feat = new Bio::SeqFeature::Generic(-primary_tag => $primary_tag, -strand => (($line[8] eq "+") ? 1 : (($line[8] eq "-") ? -1 : 0)), -start => $line[11], -end => $line[12], -source_tag => $source_tag, -tag => { percent_identity => sprintf("%.1f", $line[21]."%"), chromosome => $line[13], start => $line[15], end => $line[16], assembly => $assembly } );; my $pfeat = $dbadp->create_persistent($feat); #make persistent $dbseq->add_SeqFeature($pfeat); # add the feature to the sequence $dbseq->store(); # store in the database # retrieve the sequences - new annotations show up my $pseq = $dbadp->get_object_adaptor("Bio::SeqI")->find_by_primary_key($dbseq->primary_key); my @features = $pseq->get_SeqFeatures(); foreach my $feat (@features) { my @tags = $feat->get_all_tags(); print "tags from pseq:\n"; foreach (@tags) { print $_,"\t"; print $feat->get_tag_values($_),"\n"; } } From hlapp at gnf.org Wed Sep 7 13:30:25 2005 From: hlapp at gnf.org (Hilmar Lapp) Date: Wed Sep 7 13:23:52 2005 Subject: [BioSQL-l] having trouble creating persistent features In-Reply-To: <3cfaa4040509070842344db77e@mail.gmail.com> References: <3cfaa4040509070842344db77e@mail.gmail.com> Message-ID: <0ee3a0f15d800963c8906be6a8063a69@gnf.org> On Sep 7, 2005, at 8:42 AM, Amit Indap wrote: > > In my code snippet it below I retriveve the sequence from the biosql > db, add a persistent feature, and store it. Then I re-retrieve the > same sequence and see if my new sequence features show up. But when I > run another script, after the one below finishes, to list features my > newly added features do not show up. I am at a loss on what to do > next. Does the store() command commit changes to the underly biosql > database or am I missing another step? > No, there is no magic commit under the hood. You need to commit when appropriate for you. Your code snippet looks alright except that you don't have to make the feature persistent; when you call $dbseq->store() all features and annotations are made persistent automatically as a prerequisite for storing them. I also interpret your email such that when you re-retrieve the sequence within the same script you do see the added feature? But it's gone once you try with a different script? This would clearly indicate a transaction getting rolled back because it wasn't committed. -hilmar -- ------------------------------------------------------------- Hilmar Lapp email: lapp at gnf.org GNF, San Diego, Ca. 92121 phone: +1-858-812-1757 ------------------------------------------------------------- From hlapp at gnf.org Wed Sep 7 13:22:53 2005 From: hlapp at gnf.org (Hilmar Lapp) Date: Wed Sep 7 13:29:53 2005 Subject: [BioSQL-l] storing features to the database In-Reply-To: <3cfaa4040509061031558c2a32@mail.gmail.com> References: <3cfaa4040509061031558c2a32@mail.gmail.com> Message-ID: On Sep 6, 2005, at 10:31 AM, Amit Indap wrote: > Hi, > > I have the following code that attempts to add a seq feature to a > sequence in my biosql database: > > my $adp = $dbadp->get_object_adaptor("Bio::SeqI"); > > my $seq = Bio::Seq->new(-accession => $acc, > --namespace =>$namespace, > -version = $ver); Just first off - are the double dash in front of namespace and the equals after -version typos introduced by typing in a transcript, or are these verbatim in your script? Otherwise there's nothing wrong in what I can see from your code, so it should certainly work. Note that for testing whether the feature really gets serialized to the database you could run this with a single sequence and then check through SQL whether the additional feature is there. Oh, BTW you do commit at some point, right? BioSQL is transactional and the adaptors disable autocommit by default, so if you never commit you disconnecting will roll back any changes. Usually you would call $dbseq->commit() after the store(), but it is up to you which series of operations you consider a transaction (i.e., exceptions happening within the transaction will want you to $dbseq->rollback()). -hilmar > > my $dbseq = $adp->find_by_unique_key($seq); > my $feat = new Bio::SeqFeature::Generic(-primary_tag = >$primary_tag, > -strand > => 1, > -start => > 100, > -end => > 10000, > > -source_tag => 'blat' > ); > > $dbseq->add_SeqFeature($feat); > $dbseq->store; > - > I had ~20,000 sequences I added features to. Yet when I run another > script that > lists features of sequences, these records come up with no features! > > I'm not really sure what's going on. I made sure my namespace and > other parameters were correct. Maybe I should try and just run the > script again. > > Thanks, > > Amit Indap > Cornell University > > _______________________________________________ > BioSQL-l mailing list > BioSQL-l@open-bio.org > http://open-bio.org/mailman/listinfo/biosql-l > -- ------------------------------------------------------------- Hilmar Lapp email: lapp at gnf.org GNF, San Diego, Ca. 92121 phone: +1-858-812-1757 ------------------------------------------------------------- From blackpantherweiss at hotmail.com Tue Sep 27 17:57:55 2005 From: blackpantherweiss at hotmail.com (Marion Wundt Weiss) Date: Tue Sep 27 18:15:30 2005 Subject: [BioSQL-l] (no subject) Message-ID: Thank you for my suscription, Regards Marion Wundt _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/