ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/yamap/incremental_orphan.pl
Revision: 1.1
Committed: Wed Dec 13 10:42:46 2006 UTC (9 years, 4 months ago) by gawi79
Branch: MAIN
CVS Tags: HEAD
Log Message:
A QuickMine script

Line File contents
1 #!/usr/bin/perl -w
2
3
4 ##############################################
5 #SCRIPT NAME: incremental_orphan.pl
6 #DESCRIPTION: Determines which orfs are orphans as new genomes are added
7 ##############################################
8
9
10 use strict;
11
12 use Config::Simple;
13
14 my ($tag, @tags, $file, @lines, $lines, $i, $j, $orf, $field_number, @fields, $orphan, $genome);
15
16 unless (@ARGV ==2) {
17 die "\n\nUsage:\n ./orphan_count.pl count_end configfile\nPlease try again.\n\n\n";}
18
19 my $count_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 my $self_hit = $cfg->param('PARAMS.self_hit');
26 if ($self_hit == 0)
27 {
28 $genome = 0;
29 }
30 # convert since use of \t in config file results in literal \t being printed
31
32 if ($record_separator =~ "tab") {$record_separator = "\t"}
33
34 print "RECORD SEP $record_separator\n";
35
36
37 open (TAGS, "abbr.list") or die "can't open abbr.list file";
38 while ($tag = <TAGS>)
39 {
40 chomp($tag);
41 push (@tags, $tag);
42 }
43
44
45 foreach $tag (@tags)
46 {
47 $file = "$tag"."$count_end";
48 print "TAG: $tag - Generating orphan increments $file\n";
49 open (INPUT, "$file") or die "can't open file: $file";
50
51 @lines = <INPUT>;
52 close INPUT;
53 open OUT, ">$tag"."_orphan_increment.html";
54 print OUT "<PRE>Table showing orphans over time in $tag\n";
55 for ($i = 0; $i <= $#lines; $i++)
56 {
57 if ($lines[$i] ne "" && $i>0)
58 {
59 $orf = $lines[$i];
60 chomp($orf);
61 @fields = split /$record_separator/,$orf;
62 $field_number = $#fields;
63 $orphan = "Y";
64 if ($i == 1)
65 {
66 print OUT qq{$fields[0]$record_separator$fields[1]$record_separator};
67 for ($j = 2; $j < $#fields; $j++)
68 {
69 print OUT qq{$fields[$j]$record_separator};
70 print OUT qq{Orphan$record_separator};
71 if ($tag eq $fields[$j])
72 {
73 $genome = $j;
74 }
75 }
76 print OUT qq{$fields[$#fields]\n};
77 }
78 else
79 {
80 print OUT qq{$fields[0]$record_separator};
81 print OUT qq{$fields[1]$record_separator};
82 for ($j = 2; $j < $#fields; $j++)
83 {
84 print OUT qq{$fields[$j]$record_separator};
85 if ($fields[$j] == 0 || $genome == $j)
86 {
87 print OUT qq{$orphan$record_separator};
88 }
89 else
90 {
91 print OUT qq{N$record_separator};
92 $orphan = "N";
93 }
94 }
95 print OUT qq{$fields[$#fields]\n};
96 }
97 }
98 }
99 close OUT;
100 }