ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/yamap/orphan_time.pl
Revision: 1.2
Committed: Fri Dec 14 14:41:54 2007 UTC (8 years, 11 months ago) by gawi79
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
Log Message:
Included in YAMAP v1.02

Line File contents
1 #!/usr/bin/perl -w
2
3
4 ###################################
5 #SCRIPT NAME: orphan_time.pl
6 #FUNCTION: Displays number of orphans as more genomes are added.
7 ###################################
8
9
10 use strict;
11
12 use Config::Simple;
13
14 my ($tag, @tags, $file, @lines, $orphan_count, $lines, $i, $j,$k,$names, @names, $blank, @fields, $field_number, @initial_fields, $fields, $headings, $top_line);
15
16 unless (@ARGV ==2) {
17 die "\n\nUsage:\n ./orphan_time.pl time_end configfile\nPlease try again.\n\n\n";}
18
19 my $time_end = shift;
20 my $config_file = shift;
21
22 my $cfg = new Config::Simple($config_file);
23 # get the record separator from the config file
24 my $record_separator = $cfg->param('PARAMS.record_separator');
25 # convert since use of \t in config file results in literal \t being printed
26
27 if ($record_separator =~ "tab") {$record_separator = "\t"}
28
29 my $self_hit = $cfg->param('PATHS.self_hit');
30
31 if ($self_hit == 0)
32 {
33 $blank = 0;
34 }
35
36 print "RECORD SEP $record_separator\n";
37
38
39 open (TAGS, "abbr.list") or die "can't open abbr.list file";
40 open OUT, ">orphan_time.html";
41 print OUT "<PRE>Orphan Summary Table\n";
42 print OUT "Genome";
43
44 while ($tag = <TAGS>)
45 {
46 chomp($tag);
47 push (@tags, $tag);
48 }
49
50
51 $headings = 1;
52 foreach $tag (@tags)
53 {
54 $file = "$tag"."$time_end";
55 open (INPUT, "$file") or die "can't open file: $file";
56
57 @lines = <INPUT>;
58 close INPUT;
59 $top_line = $lines[1];
60 @names = split /$record_separator/, $top_line;
61 # obtain array element containing the genome currently being written
62 for ($k = 0; $k<=$#names; $k++)
63 {
64 if ($names[$k] eq $tag)
65 {
66 $blank = $k + 1;
67 }
68 }
69 # prints to file the top line
70 if ($headings == 1)
71 {
72 $top_line =~s/Orphan$record_separator//g;
73 $top_line =~s/Query[\t,]Self//;
74 $top_line =~s/[\t,]Total Libs with Hits//;
75 chomp $top_line;
76 print OUT qq{$top_line};
77 }
78 $headings = 0;
79 print OUT qq{\n$tag};
80 print "TAG: $tag - Timing orphans $file\n";
81 chomp($lines[1]);
82 @initial_fields = split /$record_separator/,$lines[1];
83 $field_number = $#initial_fields;
84 # $j starts on 3 as thats the first column containing orphan data, it then
85 # increments in two
86 for ($j = 3; $j <=$field_number; $j=$j+2)
87 {
88 print qq{j = $j genome = $tag\n};
89 if ($j == $blank)
90 {
91 print OUT qq{$record_separator -};
92 }
93 else
94 {
95 $orphan_count = 0;
96 # reads down column $j counting orphans
97 for ($i = 0; $i <= $#lines; $i++)
98 {
99 if ($lines[$i] ne "" && $i>1)
100 {
101 @fields = split /$record_separator/, $lines[$i];
102 if ($fields[$j] =~m/Y/)
103 {
104 $orphan_count++;
105 }
106 }
107 }
108 print OUT qq{$record_separator$orphan_count};
109 }
110 }
111 }