[Bioperl-l] basic problems with bioperl-db/biosql
Mikko Arvas
Mikko.Arvas at vtt.fi
Mon Oct 18 10:11:03 EDT 2004
Dear Hilmar,
Thank you so much! That really got me going, but I am afraid there will be
a few followups ;-).
You should really make a howto on this, although the examples in
Persistent_Bioperl_BOSC03.pdf offer a good way to start up
At 21:19 16.10.2004 -0700, Hilmar Lapp wrote:
>On Thursday, October 14, 2004, at 08:08 AM, Mikko Arvas wrote:
>>Hi,
>>I am trying to get started using bioperl-db, but I am failing
>>miserably.
>>I got bioperl 1.4 and the latest bioperl-db and biosql tarballs from
>>CVS on
>>SuSe 8.1.
>>I tried:
>>#!/usr/bin/perl -w
>>use strict;
>>use warnings;
>>use Bio::DB::BioDB;
>>use Bio::SeqIO;
>>my $db = Bio::DB::BioDB->new(
>> -database => 'biosql',
>> -user => 'root',
>> -dbname => 'biosql',
>> -host => 'localhost',
>> -driver => 'mysql');
>>my $in = Bio::SeqIO->new(-format => 'fasta',
>> -file => 'just_one_seq.fasta');
>>my $seq = $in->next_seq();
>>my $pseq = $db->create_persistent($seq);
>>$pseq->namespace('bioperl');
>>$pseq->create();
>>No error messages, but nothing goes into the database.
>I suspect it does go into the database but since you don't commit it
>gets rolled back when the script terminates.
>Try adding $pseq->commit.
YES, that does it! Things like $seq->remove and
$seq->add_SeqFeature($feat); $seq->store; start to work with it too.
However if I have in BioSQL something like this in bioentry and correspondingly
in biosequence:
+-------------+----------------+----------+-----------+------------+
| bioentry_id | biodatabase_id | name | accession | identifier |
+-------------+----------------+----------+-----------+------------+
| 9 | 9 | YAL001C | unknown | YAL001C |
| 12 | 9 | XX0115.2 | ma00001 | XX0115.2 |
+-------------+----------------+----------+-----------+------------+
and I do this:
#!/usr/bin/perl -w
use strict;
use warnings;
use Bio::Seq;
use Bio::Seq::SeqFactory;
use Bio::DB::BioDB;
my $db = Bio::DB::BioDB->new( -database => 'biosql', -user => 'root',
-dbname => 'biosql', -host => 'localhost', -driver => 'mysql');
my $seq =Bio::Seq->new(-primary_id => "XX0115.2",
-namespace => "bioperl");
my $seqfact = Bio::Seq::SeqFactory->new(-type=>"Bio::Seq");
my $adp = $db->get_object_adaptor($seq);
my $dbseq=$adp->find_by_unique_key($seq, -obj_factory => $seqfact);
I get the XX0115.2, but if that doesn't exist in the database I get YAL001C
instead,
which is a little bit funny. If I use instead:
my $seq =Bio::Seq->new(-accession => "XX0115.2", -namespace => "bioperl");
it works as it should.
Is this do to the fact that YAL001C doesn't have an accession, so I should
make sure
that there is always an accession or is the -primery_id search somehow
problematic and should be
avoided?
Thanks again for your help and thanks even more for upkeeping such
wonderful modules like these!
Cheers,
mikko
Mikko Arvas
VTT Biotechnology
e-mail: mikko.arvas at vtt.fi
tel: +358-(0)9-456 5827
mobile: +358-(0)44-381 0502
fax: +358-(0)9-455 2103
mail: Tietotie 2, Espoo
P.O. Box 1500
FIN-02044 VTT, Finland
More information about the Bioperl-l
mailing list