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

Annotation of /FigKernelScripts/get_nr_entries_without_sims.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : olson 1.4 #
2 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
3 :     # for Interpretations of Genomes. All Rights Reserved.
4 :     #
5 :     # This file is part of the SEED Toolkit.
6 :     #
7 :     # The SEED Toolkit is free software. You can redistribute
8 :     # it and/or modify it under the terms of the SEED Toolkit
9 :     # Public License.
10 :     #
11 :     # You should have received a copy of the SEED Toolkit Public License
12 :     # along with this program; if not write to the University of Chicago
13 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
14 :     # Genomes at veronika@thefig.info or download a copy from
15 :     # http://www.theseed.org/LICENSE.TXT.
16 :     #
17 :    
18 : overbeek 1.1 use FIG;
19 :     my $fig = new FIG;
20 :    
21 : overbeek 1.3 # usage: get_nr_entries_without_sims [NR SimsDir]
22 :    
23 :     my $usage = "get_nr_entries_without_sims [NR SimsDir]";
24 :    
25 :     my($nr, $sims_dir);
26 :     if (@ARGV == 0)
27 :     {
28 :     $nr = $FIG_Config::global/nr;
29 :     $sims_dir = $FIG_Config::data/Sims;
30 :     }
31 :     elsif (@ARGV == 2)
32 :     {
33 :     $nr = shift @ARGV;
34 :     $sims_dir = shift @ARGV;
35 :     }
36 :     else
37 :     {
38 :     die $usage;
39 :     }
40 :    
41 :     open(NR, "<$nr") or die "cannot open NR $nr: $!\n";
42 :     opendir(SIMS, $sims_dir) or die "could not open sims directory $sims_dir: $!\n";
43 : overbeek 1.1
44 : overbeek 1.2 @files = grep { $_ !~ /^\./ } readdir(SIMS);
45 :     closedir(SIMS);
46 :    
47 :     foreach $file (sort @files)
48 :     {
49 :     print STDERR "processing $file\n";
50 : overbeek 1.3 open(SIM,"cut -f1 $sims_dir/$file |")
51 : overbeek 1.2 || die "could not open $file";
52 :     while (defined($_ = <SIM>) && ($_ =~ /^(\S+)/))
53 :     {
54 :     $has_sims{$1} = 1;
55 :     }
56 :     close(SIM);
57 :     }
58 :     print STDERR "finished processing SIM files\n";
59 : overbeek 1.1
60 : overbeek 1.3 if (open(NR,"<$nr"))
61 : overbeek 1.1 {
62 :     $/ = "\n>";
63 :     while (defined($_ = <NR>))
64 :     {
65 :     chomp;
66 :     if ($_ =~ /^>?(\S+)[^\n]*\n(.*)/s)
67 :     {
68 :     $id = $1;
69 :     $seq = $2;
70 :     $seq =~ s/\s//gs;
71 : overbeek 1.2 if (! $has_sims{$id})
72 : overbeek 1.1 {
73 :     print ">$id\n$seq\n";
74 :     }
75 :     }
76 :     }
77 :     close(NR);
78 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3