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

Diff of /FigKernelScripts/index_nr.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Fri Apr 13 20:55:13 2007 UTC revision 1.2, Mon Apr 16 21:42:31 2007 UTC
# Line 5  Line 5 
5  # Create a btree indexed version of the given NR.  # Create a btree indexed version of the given NR.
6  #  #
7    
8  my $usage = "index_nr nr-file  index-nr-file";  my $usage = "index_nr nr-file  index-nr-file length-nr-index";
9    
10  @ARGV == 2 or die $usage;  @ARGV == 3 or die $usage;
11    
12  my $nr = shift;  my $nr = shift;
13  my $inr = shift;  my $inr = shift;
14    my $lnr = shift;
15    
16  open(NR, "<$nr") or die "Cannot open NR $nr: $!\n";  open(NR, "<$nr") or die "Cannot open NR $nr: $!\n";
17    
# Line 19  Line 20 
20  my $db = tie %idx, "DB_File", $inr, O_RDWR | O_CREAT, 0666, $DB_BTREE;  my $db = tie %idx, "DB_File", $inr, O_RDWR | O_CREAT, 0666, $DB_BTREE;
21  $db or die "Cannot create btree $inr: $!\n";  $db or die "Cannot create btree $inr: $!\n";
22    
23    my %lidx;
24    
25    my $ldb = tie %lidx, "DB_File", $lnr, O_RDWR | O_CREAT, 0666, $DB_BTREE;
26    $ldb or die "Cannot create btree $lnr: $!\n";
27    
28    
29  $/ = "\n>";  $/ = "\n>";
30  while (defined($_ = <NR>))  while (defined($_ = <NR>))
# Line 30  Line 36 
36          my $seq =  $2;          my $seq =  $2;
37          $seq =~ s/\s//gs;          $seq =~ s/\s//gs;
38          $idx{$id} = $seq;          $idx{$id} = $seq;
39            $lidx{$id} = length($seq);
40        }
41        if ($. % 100000 == 0)
42        {
43            print "$.\n";
44      }      }
45  }  }
46  close(NR);  close(NR);
47  $db->sync();  $db->sync();
48  untie %idx;  untie %idx;
49    $ldb->sync();
50    untie %lidx;
51    
52    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3