Mercurial > repos > amadeo > amadeo
comparison Tools/CREF/shorten-headers-galaxy.pl @ 3:b30ba2b06326 draft
Uploaded
author | amadeo |
---|---|
date | Mon, 05 Sep 2016 06:01:48 -0400 |
parents | 229d36377838 |
children |
comparison
equal
deleted
inserted
replaced
2:607d7bdfb07f | 3:b30ba2b06326 |
---|---|
1 #!/usr/bin/perl -w | |
2 | |
3 $|=1; | |
4 use strict; #using this makes debugging your code much easier | |
5 use warnings; | |
6 | |
7 #Script to take a multiple fasta file and truncate the header lines to | |
8 #GeneIDs so the fasta file can be used as input to AME | |
9 | |
10 #Checking to see if the user has provided 2 arguments - which is the | |
11 #name of the promoter sequence file and an output file name | |
12 | |
13 if(@ARGV < 2){ | |
14 print "\nUsage:shorten-headers.pl promoters.fasta promoters-sh.fasta\n\n"; | |
15 exit(0); | |
16 } | |
17 | |
18 #Declaring variables | |
19 my $line; # a scalar varaible | |
20 | |
21 #Using a FIELHANDLE to open the input file | |
22 open (INPUT, "<$ARGV[0]") || | |
23 die "File '$ARGV[0]' not found\n" ; | |
24 | |
25 #Using a FIELHANDLE to open the input file | |
26 open (OUTPUT, ">$ARGV[1]") || | |
27 die "File '>$ARGV[1]' not found\n" ; | |
28 | |
29 #looping through each line of the file | |
30 while (<INPUT>){ | |
31 #assigning line to variable $line | |
32 #$_ is a special default variable that here holds the line contents | |
33 $line = $_; | |
34 #match lines header lines | |
35 if ($line =~ /^>/){ | |
36 #printing header lines to file as a substring of x charaters | |
37 printf OUTPUT "%s\n", substr($line,0,21); #the third number is the x characters of the name of the header | |
38 } | |
39 else{ | |
40 #printing out sequence lines just as they are in the orginal file. | |
41 printf OUTPUT "$line"; | |
42 } | |
43 } | |
44 | |
45 close (INPUT); | |
46 close(OUTPUT); |