[Bio] / FigKernelPackages / NRTools.pm Repository:
ViewVC logotype

Annotation of /FigKernelPackages/NRTools.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download) (as text)

1 : olson 1.1 #
2 :     # Tools for dealing with nonredundant databases - finding sources, building NR, etc.
3 :     #
4 :    
5 :     package NRTools;
6 :    
7 :     use base qw(Exporter);
8 :     use vars qw(@EXPORT);
9 :    
10 :     @EXPORT = qw(scan_NR_dir scan_seed_dir);
11 :    
12 :    
13 :     =head3 scan_NR_dir()
14 :    
15 :     usage: scan_NR_dir(\%nr_hash, $dirname)
16 :    
17 :     Scan a directory containing SEED-formatted NR directories, and fill in
18 :     %nr_hash with entries of the form $nr_hash->{name} = { name => dirname, path => full path to NR dir, size => size of fasta file}
19 :    
20 :     =cut
21 :    
22 :     sub scan_NR_dir
23 :     {
24 :     my($nr_hash, $dir) = @_;
25 :    
26 :     my $dh = new DirHandle($dir);
27 :     while (defined($_ = $dh->read()))
28 :     {
29 :     next if /^\./;
30 :     my $path = "$dir/$_";
31 :     my $fasta = "$path/fasta";
32 :     if (-f $fasta)
33 :     {
34 :     if (! -f "$path/assigned_functions")
35 :     {
36 :     warn "NR directory $path missing assigned_functions\n";
37 :     }
38 :     if (! -f "$path/org.table")
39 :     {
40 :     warn "NR directory $path missing org.table\n";
41 :     }
42 :     $nr_hash->{$_} = { type => "NR", name => $_, path => $path, fasta_path => $fasta, size => -s $fasta };
43 :     }
44 :     }
45 :     $dh->close();
46 :     }
47 :    
48 :     =head3 scan_seed_dir()
49 :    
50 :     usage: @fasta = scan_seed_dir(\%nr_hash, dirname)
51 :    
52 :     Scan a SEED organism directory, creating entries as in scan_NR_dir.
53 :    
54 :     =cut
55 :    
56 :     sub scan_seed_dir
57 :     {
58 :     my($nr_hash, $dir, $opts) = @_;
59 :    
60 :     my $dh = new DirHandle($dir);
61 :     my $n = 0;
62 :     while ($_ = $dh->read())
63 :     {
64 :     next if /^\./;
65 :     #next if /^9999999.\d+$/;
66 :    
67 :     #
68 :     # Strip environmental sequences.
69 :     #
70 :     # c.f. seed-tech mail thread of 2/8/2007 for discusson on the rationale of the following
71 :     # logic.
72 :     #
73 :     # next if $fig->is_environmental($_);
74 :     next if /^4{7}/ or /^9{7}/;
75 :    
76 :     my $path = "$dir/$_";
77 :    
78 :     next unless -d $path;
79 :     next if (-e "$path/DELETED");
80 :    
81 :     my $fasta = "$path/Features/peg/fasta";
82 :     if (-f $fasta)
83 :     {
84 :     $nr_hash->{$_} = { type => "seed_org", name => $_, path => $path,
85 :     fasta_path => $fasta, size => -s _ };
86 :     }
87 :     last if $opts->{limit} && $n++ > $opts->{limit};
88 :     }
89 :     $dh->close();
90 :     }
91 :    
92 :     1;
93 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3