ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/yamap/paralogue_count.pl
Revision: 1.1
Committed: Wed Dec 13 10:46:19 2006 UTC (9 years, 8 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: paralogue_count.pl
6 #DESCRIPTION: Determines which orfs have paralogues but aren't present in other genomes
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, $genome, %paralogous, $paralogous);
15
16 # get this from the command line
17
18 unless (@ARGV ==2) {
19 die "\n\nUsage:\n ./paralogue_count.pl count_end configfile\nPlease try again.\n\n\n";}
20
21 my $count_end = shift;
22 my $config_file = shift;
23
24 my $cfg = new Config::Simple($config_file);
25 # get the record separator from the config file
26 my $record_separator = $cfg->param('PARAMS.record_separator');
27 # convert since use of \t in config file results in literal \t being printed
28
29 if ($record_separator =~ "tab") {$record_separator = "\t"}
30
31 print "RECORD SEP $record_separator\n";
32
33
34 open (TAGS, "abbr.list") or die "can't open abbr.list file";
35
36 while ($tag = <TAGS>)
37 {
38 chomp($tag);
39 push (@tags, $tag);
40 }
41 open OUT, ">paralogous_orphans.html";
42 print OUT "<PRE>Table showing paralogous orphans in all query genomes\n";
43 print OUT "Genome$record_separator"."Paralogue$record_separator"."Number of Paralogues\n";
44 foreach $tag (@tags)
45 {
46 my $para_count = 0;
47 $file = "$tag"."$count_end";
48 print "Counting paralogues : $tag\n";
49 open (INPUT, "$file") or die "can't open file: $file";
50
51 @lines = <INPUT>;
52 close INPUT;
53 for ($i = 0; $i <= $#lines; $i++)
54 {
55 if ($lines[$i] ne "" && $i>0)
56 {
57 $orf = $lines[$i];
58 chomp($orf);
59 @fields = split /$record_separator/,$orf;
60 $field_number = $#fields;
61 if ($i == 1)
62 {
63 for ($j = 2; $j < $#fields; $j++)
64 {
65 if ($tag eq $fields[$j])
66 {
67 $genome = $j;
68 }
69 }
70 }
71 else
72 {
73 if ($fields[$genome] > 1 && $fields[$field_number] == 1)
74 {
75 print OUT "$tag$record_separator$fields[0]$record_separator$fields[$genome]\n";
76 $para_count++;
77 }
78 }
79 }
80 }
81 print "$para_count\n";
82 $paralogous{$tag} = $para_count;
83 }
84 open COUNT, ">paralogue_count.html";
85 print COUNT "<PRE>Paralogue orphan count for each genome\n";
86 foreach $tag (@tags)
87 {
88 print COUNT "$tag$record_separator$paralogous{$tag}\n";
89 }
90 close OUT;
91 close COUNT;