annotate tcoffee.pl @ 5:68d71c67ef8a draft

Deleted selected files
author ayllon
date Sun, 07 Sep 2014 04:40:49 -0400
parents 5e358a278d8f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
1 #!/usr/bin/perl -w
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
2
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
3 # usage : perl script.pl <FASTA file> <method01> <method02> <method03> $dnd $msf_aln $clustalw_aln $pir_aln $fasta_aln $phylip $pir_seq $fasta_seq $score_ascii $score_html
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
4
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
5 #Chain wich will contains the paramater -output with the formats
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
6 my $outputFormat = "";
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
7 #Chain wich will contains the paramater for the -newtree, if the user wants
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
8 my $outputTree = "";
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
9 #Chain wich will contains the method of alignment of the process
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
10 my $total = "";
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
11 #Array where place the names of the formats, for the flag -output
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
12 my @formats = ("msf_aln", "clustalw_aln", "pir_aln", "fasta_aln", "phylip", "pir_seq", "fasta_seq", "score_ascii", "score_html");
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
13 #Array with the inputs for the methods of alignments
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
14 my @array = ($ARGV[1], $ARGV[2], $ARGV[3]);
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
15 #Array where will be placed the output files wich the user generate
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
16 my @files;
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
17
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
18 #Firstly the input methods of alignments are saved, if they exists (they aren't none), in the chain total, separated by commas
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
19 for (my $i = 0; $i < int(@array); $i++){
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
20 if ($array[$i] ne "None"){
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
21 $total.=$array[$i].",";
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
22 }
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
23 }
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
24
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
25 #If the user has selected the option of the tree, the chain of the tree will contains the file for the tree
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
26 if ($ARGV[4] ne "None") {
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
27 $outputTree = "-newtree ".$ARGV[4]." ";
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
28 }
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
29
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
30 #copy is a variable which save the file and the extension of each output file ([0]:file1.dat, [1]:extension_file1, [2]:file2.dat, [3]extension_file2, ...)
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
31 my $copy = -1;
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
32 @array = ($ARGV[5],$ARGV[6],$ARGV[7],$ARGV[8],$ARGV[9],$ARGV[10],$ARGV[11],$ARGV[12],$ARGV[13]);
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
33 for (my $i = 0; $i < int(@array); $i++){
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
34 if ($array[$i] ne "None"){
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
35 $outputFormat.=$formats[$i].",";
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
36 $copy++;
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
37 $files[$copy]=$array[$i];
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
38 $copy++;
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
39 $files[$copy]=$formats[$i];
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
40 }
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
41 }
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
42
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
43 #if $total contains some method, we added the flag, and remove the last comma
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
44 if ($total ne "") {
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
45 chop($total);
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
46 $total = "-method ".$total;
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
47 }
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
48
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
49 #if $outputFormat contains some output, we added the flag, and remove the last comma
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
50 #the outfile will be the first output file
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
51 #tcoffee will generate a first file without extension, with the name indicated in -outfile, but the other files will be named like this first file and the extension of the format
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
52 if ($outputFormat ne "") {
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
53 chop($outputFormat);
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
54 $outputFormat = "-output ".$outputFormat." -outfile $files[0]";
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
55 }
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
56
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
57 #execution of the tcoffee; if there are not any method or output, this chains will be empty, so anything will be ejecuted in that flag
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
58 system("t_coffee $ARGV[0] $total $outputTree $outputFormat -quiet");
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
59
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
60 #finally, as tcoffee added an extension, we have to change the extension of the files and delete it (but not from the first file, that do not add any extension)
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
61 my $fi;
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
62 if ($copy > 1) {
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
63 for (my $i = 2; $i < int(@files); $i+=2){
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
64 $fi = $files[0].".".$files[$i+1];
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
65 system ("mv $fi $files[$i]");
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
66 }
5e358a278d8f Uploaded
ayllon
parents:
diff changeset
67 }