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

Annotation of /FigKernelScripts/make_occ_counts.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : efrank 1.1 # -*- perl -*-
2 : olson 1.2 #
3 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
4 :     # for Interpretations of Genomes. All Rights Reserved.
5 :     #
6 :     # This file is part of the SEED Toolkit.
7 :     #
8 :     # The SEED Toolkit is free software. You can redistribute
9 :     # it and/or modify it under the terms of the SEED Toolkit
10 :     # Public License.
11 :     #
12 :     # You should have received a copy of the SEED Toolkit Public License
13 :     # along with this program; if not write to the University of Chicago
14 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
15 :     # Genomes at veronika@thefig.info or download a copy from
16 :     # http://www.theseed.org/LICENSE.TXT.
17 :     #
18 :    
19 : efrank 1.1
20 :     use Carp;
21 :     use Data::Dumper;
22 :     use FIG;
23 :    
24 :     my $fig = new FIG;
25 :     $| = 1;
26 :    
27 :     # usage: make_occ_counts CutOff > counts
28 :    
29 :     ( $cutoff = shift @ARGV)
30 :     || die "usage: make_occ_counts CutOff > counts";
31 :    
32 :     opendir(SIMS,"$FIG_Config::data/Sims") || die "could not open Sims";
33 :     @files = grep { $_ !~ /^\./ } readdir(SIMS);
34 :     closedir(SIMS);
35 :    
36 :     foreach $file (@files)
37 :     {
38 :     &process("$FIG_Config::data/Sims/$file");
39 :     }
40 :    
41 :     sub process {
42 :     my($file) = @_;
43 :     my(%seen,$x,$curr,$count);
44 :    
45 :     open(TMP,"<$file") || die "could not open $file";
46 :    
47 :     if (defined($x = <TMP>))
48 :     {
49 :     chop $x;
50 :     $x = [split(/\t/,$x)];
51 :     }
52 :     while (defined($x))
53 :     {
54 :     $curr = $x->[0];
55 :     $count = 0;
56 :     undef %seen;
57 :     while (defined($x) && ($x->[0] eq $curr))
58 :     {
59 :     if ((! $seen{$x->[1]}) && ($x->[10] <= $cutoff))
60 :     {
61 :     $seen{$x->[1]} = 1;
62 :     $count++;
63 :     }
64 :    
65 :     if (defined($x = <TMP>))
66 :     {
67 :     chop $x;
68 :     $x = [split(/\t/,$x)];
69 :     }
70 :     }
71 :     print "$count\t$curr\n";
72 :     }
73 :     close(TMP);
74 :     }
75 :    
76 :     undef $fig;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3