[BioSQL-l] having trouble creating persistent features

Amit Indap indapa at gmail.com
Wed Sep 7 11:42:56 EDT 2005


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";
	}
    }



More information about the BioSQL-l mailing list