BerkeleyDB

shalu sharma <[email protected]> Fri, 25 Jan 2019 10:18:18 -0500
Newsgroups gmane.comp.lang.perl.bio.general
Message-ID <CAFb_c-HNCkZ=5fptob4OokMELKo8hp1O0UxHpyU4JJE+R1R0VA@mail.gmail.com>
--===============4305838620491023381==
Content-Type: multipart/alternative; boundary="000000000000dbb826058049d69e"

--000000000000dbb826058049d69e
Content-Type: text/plain; charset="UTF-8"

Hey everyone,
     So I am using this BerkeleyDB to make a huge database (tree method).
I use it to pull out matching ids (its working fine) from multiple datasets.
 here are few lines of the code:

use strict ;

use BerkeleyDB ;

use Bio::SeqIO;

my $filename = "tree" ;

unlink $filename ;

my %h ;

tie %h, 'BerkeleyDB::Btree',

                -Filename   => $filename,

                -Flags      => DB_CREATE,

    or die "Cannot open $filename: $!\n" ;


 # Add a key/value pair to the file

open(IN,"$ARGV[0]");                    # adding values

while(<IN>){

     my $line = $_;

     chomp($line);

     my @f = split('\t',$line);

     my $id = $f[0];my $val = $f[1];$id =~ s/^\s+//;$id =~ s/\s+$//;

     $val =~ s/^\s+//;$val =~ s/\s+$//;

     $h{$id} = $val;
----
----
My question is that: It makes a huge tree file. Is it possible to re-use
that tree file again instead of making it again and again. My query
datasets changes but not that database.

--000000000000dbb826058049d69e
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">Hey everyone,<div>=C2=A0 =C2=A0 =C2=A0So =
I am using this BerkeleyDB to make a huge database (tree method).</div><div=
>I use it to pull out matching ids (its working fine) from multiple dataset=
s.</div><div>=C2=A0here are few lines of the code:</div><div><p style=3D"ma=
rgin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:=
Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures:no-common-lig=
atures">use strict ;</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">use BerkeleyDB ;</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">use Bio::SeqIO;</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">my $filename =3D &quot;tree&quot; ;</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">unlink $filename ;</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">my %h ;</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">tie %h, &#39;BerkeleyDB::Btree&#39;,</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 -Filename =C2=A0 =3D&gt; $filename,</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 -Flags=C2=A0 =C2=A0 =C2=A0 =3D&gt; DB_CREATE,</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">=C2=A0 =C2=A0 or die &quot;Cannot open $filename: $!\=
n&quot; ;</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span style=3D"font-v=
ariant-ligatures:no-common-ligatures"></span><br></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">=C2=A0# Add a key/value pair to the file</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">open(IN,&quot;$ARGV[0]&quot;);=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # adding values</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">while(&lt;IN&gt;){</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">=C2=A0=C2=A0 =C2=A0 my $line =3D $_;</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">=C2=A0=C2=A0 =C2=A0 chomp($line);</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">=C2=A0=C2=A0 =C2=A0 my @f =3D split(&#39;\t&#39;,$lin=
e);</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">=C2=A0=C2=A0 =C2=A0 my $id =3D $f[0];my $val =3D $f[1=
];</span>$id =3D~ s/^\s+//;$id =3D~ s/\s+$//;</p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">=C2=A0=C2=A0 =C2=A0 $val =3D~ s/^\s+//;$val =3D~ s/\s=
+$//;</span></p>
<p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norma=
l;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures=
:no-common-ligatures">=C2=A0=C2=A0 =C2=A0 $h{$id} =3D $val;</span></p></div=
><div>----</div><div>----</div><div>My question is that: It makes a huge tr=
ee file. Is it possible to re-use that tree file again instead of making it=
 again and again. My query datasets changes but not that database.</div><di=
v><br></div><div><br></div><div><br></div></div></div>

--000000000000dbb826058049d69e--

--===============4305838620491023381==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Bioperl-l mailing list
[email protected]
http://mailman.open-bio.org/mailman/listinfo/bioperl-l
--===============4305838620491023381==--