comparison Tools/CREF/Extract_motif_codes_galaxy.pl @ 0:229d36377838 draft

Uploaded
author amadeo
date Mon, 05 Sep 2016 05:53:08 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:229d36377838
1 #!/usr/bin/perl -w
2
3 # The lines that start with # are comment lines that are not executed
4
5
6 $|=1;
7 use strict;
8 use warnings;
9
10
11 #Script to take output from AME (part of memesuite-org) and extract a
12 #list of the overrepresented motifs and print them to a new file
13 #called ame-motif-id.list
14
15
16 #Checking to see if the user has provided 1 argument - which is the
17 #name of the AME results file
18
19 if(@ARGV < 2){
20 print "\nUsage: Extract_motif_codes.pl ame.txt ame-shorted.txt\n\n";
21 exit(0);
22 }
23
24 #Declaring variables
25 my @cols; #an array variable
26 my $line; # a scalar varaible
27
28 #Using a FIELHANDLE to open the input file
29 open (INPUT, "<$ARGV[0]") ||
30 die "File '$ARGV[0]' not found\n" ;
31
32 open (OUTPUT, ">$ARGV[1]") ||
33 die "File '>$ARGV[1]' not found\n" ;
34
35 #looping through each line of the file
36 while (<INPUT>){
37 #assigning line to variable $line
38 #$_ is a special default variable that here holds the line contents
39 $line = $_;
40 #match lines that have Ranksum
41 if ($line =~ /Ranksum/){
42 printf OUTPUT "%s\n", $line;
43 #split the lines on white space, so each part of the line gets
44 #stored as an array element
45 @cols=split;
46 #Testing to see what line elements are stored in the array
47 #print "cols [0] is $cols[0] \n";
48 #print "cols [2] is $cols[2] \n\n";
49
50 #Now see if you can print out the array elemnent that stores the
51 #motif ID to a new file called ame-motif-id.list.
52 }
53 }
54