[Bio] / FigKernelScripts / index_nr.pl Repository:
ViewVC logotype

View of /FigKernelScripts/index_nr.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Fri Apr 13 20:55:13 2007 UTC (12 years, 9 months ago) by olson
Branch: MAIN
create btree nr index

use strict;
use DB_File;

#
# Create a btree indexed version of the given NR.
#

my $usage = "index_nr nr-file  index-nr-file";

@ARGV == 2 or die $usage;

my $nr = shift;
my $inr = shift;

open(NR, "<$nr") or die "Cannot open NR $nr: $!\n";

my %idx;

my $db = tie %idx, "DB_File", $inr, O_RDWR | O_CREAT, 0666, $DB_BTREE;
$db or die "Cannot create btree $inr: $!\n";


$/ = "\n>";
while (defined($_ = <NR>))
{
    chomp;
    if ($_ =~ /^>?(\S+)[^\n]*\n(.*)/s)
    {
	my $id  =  $1;
	my $seq =  $2;
	$seq =~ s/\s//gs;
	$idx{$id} = $seq;
    }
}
close(NR);
$db->sync();
untie %idx;



MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3