0
|
1 #!/usr/bin/perl -w
|
|
2
|
|
3 $|=1;
|
|
4 use warnings;
|
|
5 use strict;
|
|
6 #Script that looks for genes that have motifs from a certain rule.
|
|
7
|
|
8 #Declaration of variables
|
|
9 my %hash;
|
|
10 my $line;
|
|
11 my @cols;
|
|
12 my @pos;
|
|
13 my @motif;
|
|
14 my @genes;
|
|
15 my $pos1;
|
|
16 my $gene;
|
|
17 my $TF;
|
|
18 my $current_gene;
|
|
19 my $size;
|
|
20
|
|
21 if(@ARGV < 2){
|
|
22 print "\nUsage: testrules_galaxy.pl fimo.gff testrules.gff \n\n";
|
|
23 exit(0);
|
|
24 }
|
|
25
|
|
26 open(FIMO, ">$ARGV[0]") ||
|
|
27 die "File '$ARGV[0]' not found\n";
|
|
28 open(OUTPUT, "<$ARGV[1]") ||
|
|
29 die "File '<$ARGV[0]' not found\n";
|
|
30
|
|
31 $current_gene="";
|
|
32
|
|
33 while (<FIMO>) {
|
|
34 $line=$_;
|
|
35 @cols=split;
|
|
36 $TF= substr $cols[8],5,8;
|
|
37 $gene=substr $cols[0],0,21;
|
|
38 $pos1 = $cols[3];
|
|
39 $size=scalar @motif;
|
|
40 if (not exists $hash{$gene} ) {
|
|
41
|
|
42 if ($current_gene ne "") {
|
|
43 printf OUTPUT "%s\n", $current_gene, " ", "=>"," ";
|
|
44 }
|
|
45 for (my $i=0;$i<$size;$i++){
|
|
46 printf OUTPUT "%s\n", $motif[$i],"($pos[$i])","\t";
|
|
47 }
|
|
48 print "\n";
|
|
49 @motif=();
|
|
50 @pos=();
|
|
51 $current_gene=$gene;
|
|
52 push @motif,$TF;
|
|
53 push @pos, $pos1;
|
|
54
|
|
55 $hash{$gene}=1;
|
|
56
|
|
57
|
|
58 }
|
|
59
|
|
60 else {
|
|
61 push @motif,$TF;
|
|
62 push @pos, $pos1;
|
|
63 }
|
|
64
|
|
65 }
|
|
66
|
|
67 $size=scalar @motif;
|
|
68 printf OUTPUT "%s\n", $current_gene, " ", "=>"," ";
|
|
69 for (my $i=0;$i<$size;$i++){
|
|
70 printf OUTPUT "%s\n", $motif[$i],"($pos[$i])","\t";
|
|
71 }
|
|
72
|
|
73
|