ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/yamap/yamap_nogui.pl
Revision: 1.13
Committed: Fri Dec 15 18:59:10 2006 UTC (9 years, 6 months ago) by gawi79
Branch: MAIN
CVS Tags: HEAD
Changes since 1.12: +1 -1 lines
Log Message:
Added bin to path2scripts

Line File contents
1 #!/usr/bin/perl
2
3 ####################################################
4 # YAMAP: Yet Another Microbial Annotation Pipeline #
5 # 1. Run each of the programs below #
6 # 2. Convert the outputs to .tab #
7 ####################################################
8
9 use strict;
10 use threads;
11 use Bio::SeqIO;
12 use Config::Simple;
13 use Cwd;
14 use File::Basename;
15 use File::Copy;
16 use Getopt::Std;
17 use Data::Dumper;
18
19 #####################
20 # usage information #
21 #####################
22 my $usage="
23 Usage:
24
25 ./yamap.pl [-c <config_file>] [-p <path_file>] <input_files>
26
27 Options:
28
29 -c full path to user config file.
30 -p full path to path config file.
31 -q full path to quickmine config file
32 -x purge extraneous output files
33 -h print this message.
34 ";
35
36 print "Yet Another Microbial Annotation Pipeline - running...\n";
37
38 ###################
39 # setup variables #
40 ###################
41 my $pwd = getcwd;
42 my $runfile;
43 my $installdir = "/usr/local/bioinf/yamap/yamap";
44 my $converter = "yamap_embl.pl";
45 my $dbname = "self_blast";
46 my $pathfile;
47 my $condor = 0;
48 my $nothing = 0;
49 my @blastfiles;
50 my $quickfile;
51
52 ###############
53 # get options #
54 ###############
55 my %opts=();
56 getopts('c:hp:xq:',\%opts);
57 # print help message
58 if (defined $opts{h})
59 {
60 print $usage;
61 exit;
62 }
63 # get user config file info
64 if (defined $opts{c})
65 {
66 $runfile = $opts{c};
67 }
68 else
69 {
70 print "Using default configuration...\n";
71 $runfile = "$installdir/etc/yamap_run.ini";
72 }
73 # get path config file info
74 if (defined $opts{p})
75 {
76 $pathfile = $opts{p};
77 }
78 else
79 {
80 print "Using default paths...\n";
81 $pathfile = "$installdir/etc/yamap_paths.ini";
82 }
83 # get quickmine config file info
84 if (defined $opts{q})
85 {
86 $quickfile = $opts{q};
87 }
88 else
89 {
90 print "Using default configuration...\n";
91 $runfile = "$installdir/etc/quickmine.ini";
92 }
93
94
95 #####################
96 # files to annotate #
97 #####################
98 my @infiles = @ARGV;
99 unless (@infiles)
100 {
101 print "Whoops! No input files specified!\n";
102 print $usage;
103 exit;
104 }
105
106
107 # check all are fasta files
108 my @dudfiles;
109 foreach my $file (@infiles)
110 {
111 my $test_file = basename($file);
112 print "my file = $file\n";
113 my $file = Bio::SeqIO->new(-file => "$file",
114 -format => "FASTA");
115 while (my $seq = $file->next_seq())
116 {
117 my $id = $seq->display_id();
118 print "my id = $id\n";
119 if ($id eq $test_file)
120 {
121 print "\nProgram terminated. The filename and fasta header are identical. \nThis will lead to loss of data. Please change your filenames and try again\n";
122 exit;
123 }
124 my $sequence_string = $seq->seq();
125 unless ($seq->validate_seq($sequence_string))
126 {
127 push(@dudfiles, $file);
128 }
129 }
130 }
131 if (@dudfiles)
132 {
133 print "Program terminated. The following input files are not valid FASTA files:\n";
134 foreach my $file (@dudfiles)
135 {
136 print "$file\n";
137 }
138 exit;
139 }
140
141
142 # read a config file containing the options for
143 # all the scripts to be run. This to be set up
144 # by GUI.
145 my $datestring = `date +%j%H%M%S`;
146 chomp($datestring);
147 my $config = new Config::Simple("$runfile") or die "Can't open run config file $runfile: $!";
148 my $common = $config->param(-block=>'COMMON');
149 my $outdir = $common->{outdir};
150 unless (-e $outdir)
151 {
152 mkdir("$outdir") or die "Can't create $outdir: $!";
153 }
154 # Copy the sequence files to the output directory and add a file extension to their name (for use with quickmine)
155 foreach my $file (@infiles)
156 {
157 system ("cp $file $outdir");
158 my @elems = split/\//, $file;
159 my $file_name = $elems[$#elems];
160 $file_name =~s/\s/_/;
161 my $temp_file;
162 if ($file_name =~m/\./)
163 {
164 $file_name =~m/(.*)\.(.*)/;
165 $temp_file = $1;
166 }
167 else
168 {
169 $temp_file = $file_name;
170 }
171 my $ext_file_name = "$temp_file".".qm";
172 system ("mv $outdir/$file_name $outdir/$ext_file_name");
173 }
174
175
176
177
178 # another config file containing all the hardcoded paths
179 my $pathconf = new Config::Simple($pathfile) or die "Can't open path config file: $!";
180 my $proc = $pathconf->param(-block=>'PROCESSING');
181 my $parse = $pathconf->param(-block=>'PARSING');
182
183
184 # quickmine config file
185 my $quickfig = new Config::Simple("$quickfile") or die "Can't open run config file $quickfile: $!";
186
187
188 ######################################################
189 # parsers, executables, and the link between the two #
190 ######################################################
191 my @execs = qw(bigblast dbblast selfblast consblast einverted etandem palindrome trnascan msatfinder glimmer pfam transterm);
192 my %execpaths = ("bigblast" => $proc->{bigblast},
193 "dbblast" => $proc->{dbblast},
194 "selfblast" => $proc->{selfblast},
195 "consblast" => $proc->{consblast},
196 "pfam" => $proc->{pfam},
197 "mspcrunch" => $proc->{mspcrunch},
198 "formatdb" => $proc->{formatdb},
199 "einverted" => $proc->{einverted},
200 "etandem" => $proc->{etandem},
201 "palindrome" => $proc->{palindrome},
202 "trnascan" => $proc->{trnascan},
203 "msatfinder" => $proc->{msatfinder},
204 "glimmer" => $proc->{glimmer},
205 "longorfs" => $proc->{longorfs},
206 "extract" => $proc->{extract},
207 "build_icm" => $proc->{build_icm},
208 "formatdb" => $proc->{formatdb},
209 "transterm" => $proc->{transterm},
210 "rbs" => $proc->{rbs});
211 my %parsers = ("bigblast" => $parse->{bigblast},
212 "dbblast" => $parse->{dbblast},
213 "selfblast" => $parse->{selfblast},
214 "consblast" => $parse->{consblast},
215 "pfam" => $parse->{pfam},
216 "einverted" => $parse->{einverted},
217 "etandem" => $parse->{etandem},
218 "palindrome" => $parse->{palindrome},
219 "trnascan" => $parse->{trnascan},
220 "msatfinder" => $parse->{msatfinder},
221 "glimmer" => $parse->{glimmer},
222 "repfinder" => $parse->{repfinder},
223 "transterm" => $parse->{transterm},
224 "rbs" => $parse->{rbs},
225 "quickmine" => $parse->{quickmine});
226 my %realname = ("bigblast" => "big_blast.pl",
227 "dbblast" => "blastall",
228 "selfblast" => "blastall",
229 "consblast" => "blastall",
230 "rbs" => "rbs_finder.pl",
231 "glimmer" => "glimmer2",
232 "pfam" => "pfam_scan.pl",
233 "longorfs" => "long-orfs",
234 "trnascan" => "tRNAscan-SE",
235 "build_icm" => "build-icm");
236
237 #################################################
238 # check that all the execpaths are in the $PATH #
239 #################################################
240 my @missing = ();
241 my $skipblast = 0;
242 foreach my $bin (keys %execpaths)
243 {
244 # only run if this program is required
245 if ($bin =~ /blast/) { $skipblast++ }
246 next if ($skipblast > 1);
247 next if ($common->{$bin} eq "0");
248 my $real;
249 if (defined $realname{$bin})
250 {
251 $real = $realname{$bin};
252 }
253 else
254 {
255 $real = $bin;
256 }
257 my $elsewhere = "$bin found, but not where your config file says it should be. Continuing...\n";
258 # check the various places it could be...
259 if (-e $execpaths{$bin})
260 {
261 next;
262 }
263 else
264 {
265 my $search = `which $real 2> /dev/null`;
266 chomp($search);
267 if ($search =~ /aliased to (\.+)/)
268 {
269 $execpaths{$bin} = $1;
270 print $elsewhere;
271 }
272 elsif (-x $search)
273 {
274 $execpaths{$bin} = $search;
275 print $elsewhere;
276 }
277 else
278 {
279 push(@missing, $real);
280 }
281 }
282 }
283
284 # warn the user if missing stuff
285 if (@missing)
286 {
287 print "The following programs were not found on this system: @missing\n";
288 print "Please add the full path to each dependency to the configuration file and try again.\n";
289 exit;
290 }
291
292 my $len = @infiles;
293 ##########################################
294 # run quickmine if needed #
295 ##########################################
296 if ($common->{quickmine} == 1 and $len => 1)
297 {
298 system("perl $installdir/bin/quickmine.pl -c $quickfile");
299
300
301 }
302
303 ##########################################
304 # create a self-blast database if needed #
305 ##########################################
306 my $formatdb = $execpaths{formatdb};
307 my @catfiles = ();
308 if ($common->{selfblast} == 1 and $len > 1)
309 {
310 print "Preparing self blast database...\n";
311 # clean up old d
312 if (-e "$outdir/$dbname")
313 {
314 unlink("$outdir/$dbname") or die "Can't remove old self-blast database: $!";
315 }
316 # cat only the other file to the db if there are two files
317 my @dbfiles;
318 if ($len == 2)
319 {
320 push (@catfiles, $infiles[1]);
321 }
322 else
323 {
324 foreach my $cf (@infiles) { push (@catfiles, $cf); }
325 }
326 # create new
327 if (system("cat @catfiles >> $outdir/$dbname") == 0)
328 {
329 if (system("cd $outdir; $formatdb -i $dbname -o F -p F") == 0)
330 {
331 print "$dbname formatting complete.\n";
332 }
333 else
334 {
335 warn "Could not run formatdb.";
336 }
337 }
338 else
339 {
340 print "Could not create $dbname: $!";
341 }
342 }
343 elsif ($common->{selfblast} == 1 and $len == 1)
344 {
345 print "Single sequence only - self-blast will not be run.\n";
346 }
347
348 ####################################
349 # glimmer is needed if pfam is run #
350 ####################################
351 if ($common->{pfam} == 1)
352 {
353 unless ($common->{glimmer} == 1)
354 {
355 print "Activating glimmer - needed for pfam.\n";
356 $common->{glimmer} = 1;
357 }
358 }
359 ########################################
360 # glimmer is also needed for transterm #
361 ########################################
362 if ($common->{transterm} == 1)
363 {
364 unless ($common->{glimmer} == 1)
365 {
366 print "Activating glimmer - needed for transterm.\n";
367 $common->{glimmer} = 1;
368 }
369 }
370 ######################################
371 # run each of the annotation methods #
372 ######################################
373 my %artline=();
374 my ($out,@seqfiles, $multiseq);
375
376 foreach my $infile (@infiles)
377 {
378 # setup input file name and output directory name
379 $infile = [split(/\//,$infile)]->[-1];
380 my @tabfiles = ();
381
382 # oh dear. Some people insist upon putting in FASTA
383 # files with many sequences in them rather than the
384 # one-file-per-metagenomic-sequence that I was expecting.
385 # However, this can be dealt with using the power of SeqIO.
386 # First, we must determine if the file has multiple sequences.
387 $multiseq = 0;
388 my $fastas = 0;
389 my @slurp = ();
390 open (CHECK, "<$infile") or die "Can't check $infile for No. of seqs. $!";
391 while (my $line = <CHECK>)
392 {
393 $fastas++ if ($line =~ /^>/);
394 if ($fastas > 1)
395 {
396 $multiseq = 1;
397 last;
398 }
399 }
400 close CHECK;
401
402 if ($multiseq == 1)
403 {
404 my $parsed_files_already = $quickfig->param('RUN.parse');
405 #check to see if files have already been split up using quickmine
406 # if not they need to be processed now
407 if ($common->{quickmine} != 1 || $parsed_files_already != 1)
408 {
409 # set quickmine config file so writes individual fasta files
410 $quickfig->param("LEAVE_ALONE.write_fasta_files", 1);
411 $quickfig -> save();
412 # run script responsible for splitting the files
413 system("perl $installdir/2qmfasta.pl $quickfile");
414 }
415 $infile =~m/(.*)\.(.*)/;
416 my $temp_file = $1;
417 my $temp_command = "$outdir/$temp_file"."orf*fasta";
418 # this line may cause problems such as list too long, check for alternatives
419 my @temp_seqfiles = `ls $temp_command`;
420 foreach my $seqfile (@temp_seqfiles)
421 {
422 $seqfile =~m/$outdir\/(.*\.fasta)/;
423 my $id = $1;
424 push (@seqfiles, $id);
425 $out = $outdir . "/" . $id . ".out";
426 unless (-e $out)
427 {
428 mkdir("$out") or die "Can't create $out: $!";
429 }
430 system("ln -sf $pwd/$outdir/$id $pwd/$out/$id") == 0 or warn "Can't link genome file: $!";
431 foreach my $exec (@execs)
432 {
433 if ($common->{$exec} == 1)
434 {
435 $nothing = 1;
436 # create a thread for each of the annotation steps
437 # each thread to run its own condor job
438 my $pass = "$id" . "|" . $exec . "|" . $out;
439 my $pass = $id . "|" . $exec . "|" . $out;
440 my $subroutine = "run_" . $exec;
441 my $thr = threads->new("$subroutine","$pass");
442 my $made = $thr->join();
443
444 # remember which files go with each genome
445 foreach my $file (@$made)
446 {
447 push(@{$artline{$id}}, $file);
448 }
449 }
450 }
451 if ($common->{quickmine} == 1)
452 {
453 my $quick_parse = $parsers{quickmine};
454 system("perl $quick_parse $id $out $multiseq $quickfile")
455
456 }
457 print "Converting output to EMBL format...$out\n";
458 print "$installdir/bin/$converter $id $out $multiseq\n";
459 if (system("perl $installdir/bin/$converter $id $out $multiseq") == 0)
460 {
461 print "File converter finished.\n";
462 }
463 else
464 {
465 warn "Could not run converter.";
466 }
467 }
468 }
469 else
470 {
471 # use seqio to get an id
472 my $basefile = Bio::SeqIO->new(-file => "$infile", -format => 'Fasta');
473
474 while (my $seq = $basefile->next_seq())
475 {
476 my $id = $seq->display_id();
477 $id =~ s/[\.|\||:|,|;]/_/g;
478 if ($id eq "")
479 {
480 print "Invalid name in FASTA header. Please replace with something like \"seq1\", \"seq2\" etc.\nExiting!\n";
481 next;
482 }
483 push (@seqfiles, $id);
484
485 # the output directory should be named based on the seq id
486 $out = $outdir . "/" . $id . ".out";
487 unless (-e $out)
488 {
489 mkdir("$out") or die "Can't create $out: $!";
490 }
491
492 # this file should be written out to a temp. file
493 # for the various progs to run on it, and delete afterwards.
494 # use a symlink instead if the file is a single seq, to save
495 # on disk space
496
497 system("ln -sf $pwd/$infile $pwd/$out/$id") == 0 or die "Can't symlink $id to $infile: $!";
498
499 # run the outputs:
500 # threading - go through each genome in turn, but spawn a
501 # separate thread for each of the execs. This allows the use
502 # of "die" in each thread. Threads must be joined rather than
503 # detached at present in order to wait for completion.
504 # This is slow, but will be changed in future to detach threads
505 # containing condor DAG jobs &c.
506 foreach my $exec (@execs)
507 {
508 if ($common->{$exec} == 1)
509 {
510 $nothing = 1;
511 # create a thread for each of the annotation steps
512 # each thread to run its own condor job
513 my $pass = "$id" . "|" . $exec . "|" . $out;
514 my $pass = $id . "|" . $exec . "|" . $out;
515 my $subroutine = "run_" . $exec;
516 my $thr = threads->new("$subroutine","$pass");
517 my $made = $thr->join();
518
519 # remember which files go with each genome
520 foreach my $file (@$made)
521 {
522 push(@{$artline{$id}}, $file);
523 }
524 }
525 }
526 if ($common->{quickmine} == 1)
527 {
528 my $quick_parse = $parsers{quickmine};
529 print "parse = $quick_parse\n";
530 system("perl $quick_parse $id $out $multiseq $quickfile")
531 }
532 print "Converting output to EMBL format...$out\n";
533 print "$installdir/bin/$converter $id $out $multiseq\n";
534 if (system("perl $installdir/bin/$converter $id $out $multiseq") == 0)
535 {
536 print "File converter finished.\n";
537 }
538 else
539 {
540 warn "Could not run converter.";
541 }
542 }
543 }
544 }
545
546 # exit early if no options set
547 if ($nothing == 0)
548 {
549 print "No options were set, so no annotation programs were run.\n";
550 print "\nYAMAP finished!\n";
551 exit;
552 }
553
554
555 # convert output files to EMBL format
556 #if (@seqfiles & $multiseq != 1)
557 #{
558 # print "Converting output to EMBL format...$out\n";
559 # if (system("cd $out; $installdir/bin/$converter @seqfiles") == 0)
560 # {
561 # print "File converter finished.\n";
562 # }
563 # else
564 # {
565 # warn "Could not run converter.";
566 # }
567 #}
568 #elsif (@seqfiles & $multiseq == 1)
569 #{
570 # print "Multiple sequences - skipping EMBL conversion...\n";
571 #}
572 #else
573 #{
574 # print "No output - skipping EMBL conversion...\n";
575 #}
576
577 #################################################
578 # print out a handy summary of what was created #
579 #################################################
580 my $printout = 0;
581 foreach my $infile (@seqfiles)
582 {
583 if (defined @{$artline{$infile}})
584 {
585 $printout = 1;
586 last;
587 }
588 }
589 if ($printout == 1)
590 {
591 print "Output files can be found in the following directories:\n\n";
592 foreach my $infile (@seqfiles)
593 {
594 if (defined @{$artline{$infile}})
595 {
596 print "$pwd/$outdir/$infile.out\n";
597 }
598 }
599 }
600 else
601 {
602 print "No output files created.\n";
603 }
604
605 # cleanup last file
606 if ($common->{msatfinder} == 1)
607 {
608 unlink("msatfinder.rc");
609 }
610
611 # cleanup all extra seq files
612 if (defined $opts{x})
613 {
614 foreach (@seqfiles) { unlink $_; }
615 }
616
617 # Finished
618 print "\nYAMAP finished!\n";
619
620 #######################################
621 # subroutines for each of the methods #
622 #######################################
623 # DBBLAST
624 sub run_dbblast
625 {
626 # now re-written to use blastall directly...
627 # get the config details
628 my $incoming = shift;
629 my @parts = split(/\|/, $incoming);
630 my $infile = $parts[0];
631 my $exec = $parts[1];
632 my $out = $parts[2];
633 my $conf = uc $exec;
634 my $blast = $execpaths{dbblast};
635 my $blast_parse = $parsers{dbblast};
636 my $bconf = $config->param(-block=>"$conf");
637 my $program = $bconf->{program};
638 my $jobs = $bconf->{jobs};
639 my $other_opts = $bconf->{other_opts};
640 my @outfiles;
641
642 # set the correct database
643 my $database;
644 my $base = &basename($infile);
645 my $dir = &dirname($infile);
646 if ($exec eq "dbblast")
647 {
648 $database = $bconf->{database};
649 }
650 elsif ($exec eq "selfblast")
651 {
652 $database = "../self_blast";
653 }
654 elsif ($exec eq "selfblast")
655 {
656 warn "This option is not yet available.\n";
657 exit;
658 }
659 else
660 {
661 warn "ERROR: Something odd has happened with the blastall routine.\n";
662 exit;
663 }
664
665 # only blast once if using "bl2seq"
666 if ($len == 2 and $exec eq "selfblast")
667 {
668 return if (&basename($infile) eq $infiles[1]);
669 }
670
671 # exit if only one seq
672 if ($len == 1 and $exec eq "selfblast")
673 {
674 return;
675 }
676
677 # get the correct program
678 my %progs = ("blastn" => "-p blastn",
679 "blastx" => "-p blastx",
680 "blastp" => "-p blastp",
681 "tblastx" => "-p tblastx");
682
683 # run blast
684 print "Running $exec on $infile...\n";
685 if ($dir eq ".") { $dir = $pwd; }
686
687 # collect the output in order to see if there are any warnings from blast
688 # failing to run for whatever reason
689 my @output = `cd $dir/$out; $blast -d $database -i $infile $progs{$program} -m9 $other_opts 2>&1`;
690
691 # write to stdout another way
692 open (WARN, ">$dir/$out/$infile.$exec.stdout") or die "Can't write stdout for blast: $!";
693 foreach my $outerr (@output) { print WARN "$outerr"; }
694 close WARN;
695 if (grep /WARNING/, @output)
696 {
697 print "Blast error! Please check $infile.$exec.stdout for details.\n";
698 return;
699 }
700 else
701 {
702 print "Blast complete!\n";
703 &copy("$dir/$out/$infile.$exec.stdout", "$dir/$out/$infile.$exec.out") or die "Can't copy blast output: $!";
704
705 # attempt to parse the blast output
706 if (system("$blast_parse $dir/$out/$infile.$exec.out") == 0)
707 {
708 push(@outfiles, "$infile.$exec.out");
709 }
710 else
711 {
712 warn "Could not parse blast output: $!";
713 return;
714 }
715 }
716 return \@outfiles;
717 }
718 # EINVERTED
719 sub run_einverted
720 {
721 # get the config details
722 my $incoming = shift;
723 my @parts = split(/\|/, $incoming);
724 my $infile = $parts[0];
725 my $exec = $parts[1];
726 my $out = $parts[2];
727 my $einverted = $execpaths{$exec};
728 my $parse_einverted = $parsers{$exec};
729 my $econf = $config->param(-block=>'EINVERTED');
730 my $gap = $econf->{gap};
731 my $threshold = $econf->{threshold};
732 my $match = $econf->{match};
733 my $mismatch =$econf->{mismatch};
734 my $maxrepeat = $econf->{maxrepeat};
735 my @outfiles;
736
737 # run einverted
738 print "Running einverted on $infile...\n";
739 if (system("cd $out; $einverted -gap $gap -threshold $threshold -match $match -mismatch $mismatch -maxrepeat $maxrepeat -auto -outfile $infile.einverted.out $infile > $infile.einverted.stdout 2>&1") == 0)
740 {
741 if (system("cd $out; $parse_einverted $infile.einverted.out $infile.einverted.tab > $infile.einverted.stdout 2>&1") == 0)
742 {
743 print "Einverted complete!\n";
744 push (@outfiles, "$out/$infile.einverted.tab");
745 # clean up output files
746 }
747 else
748 {
749 warn "Could not parse $out/$infile.einverted.out: $!";
750 }
751 }
752 else
753 {
754 warn "Could not run $einverted on $infile.";
755 }
756 unlink("$out/$infile.einverted.out");
757 return \@outfiles;
758 }
759 # ETANDEM
760 sub run_etandem
761 {
762 # get the config details
763 my $incoming = shift;
764 my @parts = split(/\|/, $incoming);
765 my $infile = $parts[0];
766 my $exec = $parts[1];
767 my $out = $parts[2];
768 my $etandem = $execpaths{$exec};
769 my $parse_etandem = $parsers{$exec};
770 my @outfiles;
771 my $equicktandem = $etandem;
772 $equicktandem =~ s/etandem/equicktandem/;
773 my $qtanfile = "$infile.qtan.out";
774 my $tanfile = "$infile.tan.out";
775
776 # equicktandem configs
777 my $eqconf = $config->param(-block=>'EQUICKTANDEM');
778 my $maxrepeat = $eqconf->{maxrepeat};
779 my $threshold = $eqconf->{threshold};
780
781 # etandem configs
782 my $econf = $config->param(-block=>'ETANDEM');
783 my $mismatch = $econf->{mismatch};
784 my $uniform = $econf->{uniform};
785
786 # run equicktandem, parse to get min. and max sizes and
787 # feed these into etandem
788 my ($max, $min, @sizes);
789 print "Running equicktandem on $infile...\n";
790 my $runquick = 0;
791 if (system("cd $out; $equicktandem -threshold $threshold -maxrepeat $maxrepeat -outfile $qtanfile $infile > $infile.equicktandem.stdout 2>&1") == 0)
792 {
793 # get min and max repeat sizes by parsing qtan
794 open (IN, "<$out/$qtanfile") or warn "Can't open $qtanfile: $!";
795 my @lines = <IN>;
796 close IN;
797 foreach my $line (@lines)
798 {
799 next if ($line =~ /^#/ or $line =~ /Start/ or $line =~ /^\s+$/);
800 push (@sizes, [split(/\s+/,$line)]->[3]);
801 }
802 my @minmax = sort { $a <=> $b } @sizes;
803
804 # don't run if no repeats found
805 if (@minmax)
806 {
807 $max = $minmax[-1];
808 $min = $minmax[0];
809 $runquick = 1;
810 }
811 else
812 {
813 print "No repeats found; etandem will not be run.\n";
814 return;
815 }
816 }
817 else
818 {
819 warn "Could not run equicktandem - etandem will not be run.\n";
820 return;
821 }
822 unlink("$out/$qtanfile");
823
824 # run etandem on original file
825 if ($runquick == 1)
826 {
827 if (system("cd $out; $etandem -minrepeat $min -maxrepeat $max -outfile $tanfile $infile > $infile.etandem.stdout 2>&1") == 0)
828 {
829 #parse etandem
830 system("cd $out; $parse_etandem $tanfile $infile.etandem.tab");
831 push(@outfiles, "$infile.etandem.tab");
832 print "Etandem complete!\n";
833 }
834 else
835 {
836 warn "Could not run etandem!\n";
837 }
838 }
839 return \@outfiles;
840 }
841 # GLIMMER
842 sub run_glimmer
843 {
844 # glimmer is slightly different - there are more steps and more
845 # executables. This is adapated from Chimdi's glimmer_auto script
846 # get the config details
847 my $incoming = shift;
848 my @parts = split(/\|/, $incoming);
849 my $infile = $parts[0];
850 my $exec = $parts[1];
851 my $out = $parts[2];
852 my $glimmer = $execpaths{$exec};
853 my $parse_glimmer = $parsers{$exec};
854 my @outfiles;
855 my $gconf = $config->param(-block=>'GLIMMER');
856 my $args_longorfs = $gconf->{arguments_longorfs};
857 my $args_glimmer2 = $gconf->{arguments_glimmer2};
858 my $longorfs = $execpaths{longorfs};
859 my $extract = $execpaths{extract};
860 my $build_icm = $execpaths{build_icm};
861 my $rbs = $execpaths{rbs};
862 my $parse_rbs = $parse->{rbs};
863 my $stdoutfile = "$infile.glimmer.stdout";
864 my @outfiles;
865 my $continue = 1;
866
867 #######################################
868 # run glimmer components and then rbs #
869 #######################################
870 # run long-orfs
871 print "Running long-orfs on $infile...\n";
872 unless (system("cd $out; $longorfs $args_longorfs $infile > $infile.glimmer.orfs 2> $stdoutfile") == 0)
873 {
874 warn "Could not run long-orfs.";
875 print "Exiting glimmer pipeline!\n";
876 $continue = 0;
877 }
878 return unless ($continue == 1);
879 # remove header information from longorfs output
880 my @long_orfs;
881 if (!open(LONG_ORFS, "$out/$infile.glimmer.orfs"))
882 {
883 warn "Can't open $infile.glimmer.orfs for reading: $!";
884 print "Exiting glimmer pipeline!\n";
885 $continue = 0;
886 }
887 else
888 {
889 while (my $line = <LONG_ORFS>)
890 {
891 if ($line =~ /^\s*(T.*)\n/)
892 {
893 my $thing = $1;
894 push(@long_orfs, $thing);
895 }
896 }
897 }
898 close LONG_ORFS;
899 return unless ($continue == 1);
900 # write each long orf to file
901 if (!open (LONG_ORFS, ">$out/$infile.glimmer.orfs"))
902 {
903 warn "Can't open $infile.glimmer.orfs for reading: $!";
904 print "Exiting glimmer pipeline!\n";
905 $continue = 0;
906 }
907 else
908 {
909 foreach my $long_orfs (@long_orfs)
910 {
911 print LONG_ORFS "$long_orfs\n";
912 }
913 }
914 close LONG_ORFS;
915 return unless ($continue == 1);
916
917 # run extract
918 print "Running extract on $infile.glimmer.orfs...\n";
919 unless (system ("cd $out; $extract $infile $infile.glimmer.orfs > $infile.glimmer.seq 2>> $stdoutfile") == 0)
920 {
921 warn "Could not run extract.";
922 print "Exiting glimmer pipeline!\n";
923 $continue = 0;
924 }
925 return unless ($continue == 1);
926
927 # run build-icm
928 print "Running build-icm on $infile.glimmer.seq...\n";
929 unless (system ("cd $out; $build_icm < $infile.glimmer.seq > $infile.glimmer.icm 2>> $stdoutfile") == 0)
930 {
931 warn "Could not run build-icm.";
932 print "Exiting glimmer pipeline!\n";
933 $continue = 0;
934 }
935 return unless ($continue == 1);
936
937 # actually run glimmer2 at last
938 print "Running glimmer2 on $infile.glimmer.icm...\n";
939 unless (system ("cd $out; $glimmer $args_glimmer2 $infile $infile.glimmer.icm > $infile.glimmer.output 2>> $stdoutfile") == 0)
940 {
941 warn "Could not run glimmer2.";
942 print "Exiting glimmer pipeline!\n";
943 $continue = 0;
944 }
945 return unless ($continue == 1);
946 # parse glimmer output
947 if (system ("cd $out; $parse_glimmer $infile.glimmer.output > $infile.glimmer.tab 2>> $stdoutfile") == 0)
948 {
949 print "Glimmer complete!\n";
950 push (@outfiles, "$infile.glimmer.tab");
951 }
952 else
953 {
954 warn "Could not parse glimmer2: $!";
955 print "Attempting to run rbsfinder...\n";
956 }
957
958 # run rbsfinder on glimmer output
959 print "Running rbsfinder on $infile.glimmer.output...\n";
960 unless (system("cd $out; $rbs $infile $infile.glimmer.output $infile.rbs.output >> $stdoutfile 2>&1") == 0)
961 {
962 warn "Could not run rbsfinder.";
963 print "Exiting glimmer pipeline!\n";
964 $continue = 0;
965 }
966 return unless ($continue == 1);
967
968 # parse rbsfinder output
969 if (system("cd $out; $parse_rbs $infile.rbs.output $infile.rbs.tab 2> $stdoutfile") == 0)
970 {
971 print "Rbsfinder complete!\n";
972 push (@outfiles, "$infile.rbs.tab");
973 }
974 else
975 {
976 warn "Could not run rbsfinder.";
977 print "Exiting glimmer pipeline!\n";
978 $continue = 0;
979 }
980 return \@outfiles unless ($continue == 1);
981
982 # clean up intermediate files
983 my @clearup = ("$infile.glimmer.icm", "$infile.glimmer.orfs", "$infile.glimmer.output", "$infile.glimmer.seq", "$infile.rbs.output");
984 #foreach my $file (@clearup) { unlink "$out/$file"; }
985 return \@outfiles;
986 }
987 # PALINDROME
988 sub run_palindrome
989 {
990 # get the config details
991 my $incoming = shift;
992 my @parts = split(/\|/, $incoming);
993 my $infile = $parts[0];
994 my $exec = $parts[1];
995 my $out = $parts[2];
996 my $palindrome = $execpaths{$exec};
997 my $parse_palindrome = $parsers{$exec};
998 my $pconf = $config->param(-block=>'PALINDROME');
999 my $minpallen = $pconf->{minpallen};
1000 my $maxpallen = $pconf->{maxpallen};
1001 my $gaplimit = $pconf->{gaplimit};
1002 my $nummismatches = $pconf->{nummismatches};
1003 my $overlap = $pconf->{overlap};
1004 my @outfiles;
1005 my $outfile = "$infile.palindrome.out";
1006 my $tabfile = "$infile.palindrome.tab";
1007 my $stdoutfile = "$infile.palindrome.stdout";
1008
1009 # run palindrome
1010 print "Running palindrome on $infile...\n";
1011 if (system("cd $out; $palindrome -stdout -minpallen $minpallen -maxpallen $maxpallen -gaplimit $gaplimit -nummismatches $nummismatches -overlap $overlap -outfile $outfile $infile > $stdoutfile 2>&1") == 0)
1012 {
1013 if (system("cd $out; $parse_palindrome $outfile $tabfile > $stdoutfile 2>&1") == 0)
1014 {
1015 push (@outfiles, $tabfile);
1016 print "Palindrome complete!\n";
1017 }
1018 else
1019 {
1020 warn "Could not parse palindrome output: $!";
1021 }
1022 }
1023 else
1024 {
1025 warn "Could not run palindrome";
1026 }
1027 # clean up
1028 if (-e "$outfile")
1029 {
1030 unlink ("$outfile");
1031 }
1032 return \@outfiles;
1033 }
1034 # TRNASCAN
1035 sub run_trnascan
1036 {
1037 # get the config details
1038 my $incoming = shift;
1039 my @parts = split(/\|/, $incoming);
1040 my $infile = $parts[0];
1041 my $exec = $parts[1];
1042 my $out = $parts[2];
1043 my $trnascan = $execpaths{$exec};
1044 my $parse_trna = $parsers{$exec};
1045 my $tconf = $config->param(-block=>'TRNASCAN');
1046 my $searchmode = $tconf->{searchmode};
1047 my $covariance = $tconf->{covariance};
1048 my $showall = $tconf->{showall};
1049 my $other_opts = $tconf->{options};
1050
1051 # outfiles
1052 my $outfile = "$infile.trnascan.out";
1053 my $stdoutfile = "$infile.trnascan.stdout";
1054 my $tabfile = "$infile.trnascan.tab";
1055 my @outfiles;
1056
1057 # convert config file details into command line
1058 my %taxon = ("Bacterial" => "-B",
1059 "Archeal" => "-A",
1060 "Organellar" => "-O",
1061 "Eukaryotic" => "-E",
1062 "General" => "-G");
1063 my %covar = ("Y" => "-C", "N" => undef);
1064 my %show = ("Y" => "-H", "N" => undef);
1065
1066 # command line
1067 my @options;
1068
1069 # load command line
1070 push (@options, $taxon{$searchmode}) if (defined $taxon{$searchmode});
1071 push (@options, $covar{$covariance}) if (defined $covar{$covariance});
1072 push (@options, $show{$showall}) if (defined $show{$showall});
1073 push (@options, $other_opts) if (defined $other_opts);
1074
1075 # run the code
1076 my $continue = 1;
1077 print "Running tRNAscan-SE with options \"@options\" on $infile...\n";
1078 unless (system("cd $out; $trnascan @options $infile > $outfile 2> $stdoutfile") == 0)
1079 {
1080 warn "Could not run tRNAscan-SE.";
1081 $continue = 0;
1082 }
1083 return unless ($continue == 1);
1084 unless (-s "$out/$outfile")
1085 {
1086 print "No tRNAs found!\n";
1087 $continue = 0;
1088 }
1089 return unless ($continue == 1);
1090 if (system("cd $out; $parse_trna $outfile $tabfile 2>> $stdoutfile") == 0)
1091 {
1092 print "tRNAscan complete!\n";
1093 push (@outfiles,$tabfile);
1094 }
1095 else
1096 {
1097 warn "Could not parse tRNAscan-SE output: $!";
1098 }
1099 unlink("$outfile");
1100 return \@outfiles;
1101 }
1102 # SELFBLAST
1103 sub run_selfblast
1104 {
1105 my $incoming = shift;
1106 return &run_dbblast($incoming);
1107 }
1108 # CONSBLAST
1109 sub run_consblast
1110 {
1111 #my $incoming = shift;
1112 #return &run_dbblast($incoming);
1113 print "This option is not yet available.\n";
1114 }
1115 # BIGBLAST
1116 sub run_bigblast
1117 {
1118 # get the config details
1119 my $incoming = shift;
1120 my @parts = split(/\|/, $incoming);
1121 my $infile = $parts[0];
1122 my $exec = $parts[1];
1123 my $out = $parts[2];
1124 my $conf = uc $exec;
1125 my $bigblast = $execpaths{bigblast};
1126 my $bconf = $config->param(-block=>"$conf");
1127 my $database = $bconf->{database};
1128 my $program = $bconf->{program};
1129 my $jobs = $bconf->{jobs} || 1;
1130 my $other_opts = $bconf->{other_opts};
1131 my @outfiles;
1132
1133 # set the correct database
1134 my $base = &basename($infile);
1135 my $dir = &dirname($infile);
1136
1137 # get the correct program
1138 my %progs = ("blastn" => "-2",
1139 "blastx" => "-x2",
1140 "tblastx" => "-tx2");
1141
1142 # run blast
1143 print "Running $exec on $infile...\n";
1144 if ($dir eq ".") { $dir = $pwd; }
1145 if (system("cd $out; $bigblast $progs{$program} -j $jobs $database $infile $other_opts > $infile.$exec.stdout 2>&1") == 0)
1146 {
1147 print "Blast complete!\n";
1148 my @files = glob "$out/big_blast*";
1149 foreach my $file (@files)
1150 {
1151 if ($file =~ /\.\d{8}/)
1152 {
1153 unlink("$file");
1154 }
1155 else
1156 {
1157 my $newname = &basename($infile) . ".$exec." . [split(/\./, $file)]->[-1];
1158 &move("$file", "$out/$newname") or warn "Can't move $file to $newname: $!";
1159 push (@outfiles, $newname);
1160 }
1161 }
1162 }
1163 else
1164 {
1165 warn "Could not run $bigblast on $infile: $!\n";
1166 }
1167 return \@outfiles;
1168
1169 }
1170
1171 # MSATFINDER
1172 sub run_msatfinder
1173 {
1174 my $incoming = shift;
1175 my @parts = split(/\|/, $incoming);
1176 my $infile = $parts[0];
1177 my $exec = $parts[1];
1178 my $out = $parts[2];
1179
1180 # write out msatfinder config file
1181 my $msatfinder = $execpaths{$exec};
1182 my $mconf = $config->param(-block=>'MSATFINDER');
1183 my $flank_size = $mconf->{flank_size};
1184 my $mrange = $mconf->{mrange};
1185 my $engine = $mconf->{engine};
1186 my $interrupts = $mconf->{interrupts};
1187 my @outfiles;
1188
1189 # Annoyingly, when yamap.pl saves $mrange, it drops the quotes
1190 # which causes Config::Simple to convert it into an array, with
1191 # disastrous consequences. So, yamap's config file uses "+" not
1192 # ",", and this matter is corrected below:
1193 $mrange =~ s/\+/,/g;
1194
1195 # write configuration file
1196 open (CONF, ">$out/msatfinder.rc") or die "Can't open msatfinder.rc: $!";
1197 print CONF <<EOF;
1198 [COMMON]
1199 debug=0
1200 flank_size=$flank_size
1201 mine_dir="MINE/"
1202 repeat_dir="Repeats/"
1203 tab_dir="Msat_tabs/"
1204 bigtab_dir="Flank_tabs/"
1205 fasta_dir="Fasta/"
1206 prime_dir="Primers/"
1207 align_dir="Aligner/"
1208 anno_dir="Annotations/"
1209 count_dir="Counts/"
1210 [DEPENDENCIES]
1211 run_eprimer=0
1212 eprimer_args="-primer"
1213 eprimer="/usr/bin/eprimer3"
1214 primer3core="/usr/bin/primer3_core"
1215 [FINDER]
1216 override=0
1217 motif_threshold="$mrange"
1218 artemis=1
1219 mine=0
1220 fastafile=0
1221 sumswitch=0
1222 screendump=0
1223 EOF
1224 close CONF;
1225
1226 # run msatfinder
1227 my $cleanup = 0;
1228 print "Running msatfinder on $infile...\n";
1229 if (system("cd $out; $msatfinder -e $engine $infile > $infile.msatfinder.stdout 2>&1") == 0)
1230 {
1231 print "Msatfinder finished.\n";
1232 $cleanup = 1;
1233 }
1234 else
1235 {
1236 warn "Could not run $msatfinder.";
1237 return;
1238 }
1239
1240 # move tabs to the proper location
1241 # and delete all output
1242 if ($cleanup == 1)
1243 {
1244 # move
1245 my @tabs = glob "$out/Msat_tabs/*.msat_tab";
1246 foreach my $tab (@tabs)
1247 {
1248 &move("$tab", "$out/$infile.msatfinder.tab");
1249 push (@outfiles, "$infile.msatfinder.tab");
1250 }
1251 # purge
1252 my @purge = qw(results.html MINE Repeats Msat_tabs Flank_tabs Fasta Primers Aligner Annotations Counts msatfinder.rc);
1253 foreach my $pu (@purge)
1254 {
1255 system("rm -rf $out/$pu") == 0 or warn "Can't unlink $pu: $!";
1256 }
1257 }
1258 return \@outfiles;
1259 }
1260
1261 # PFAM
1262 sub run_pfam
1263 {
1264 unless ($common->{glimmer} == 1)
1265 {
1266 print "Pfam cannot be run without glimmer's output. Skipping...\n";
1267 return;
1268 }
1269 my $incoming = shift;
1270 my @parts = split(/\|/, $incoming);
1271 my $infile = $parts[0];
1272 my $exec = $parts[1];
1273 my $out = $parts[2];
1274
1275 my $conf = uc $exec;
1276 my $pconf = $config->param(-block=>"$conf");
1277 my $db = $pconf->{database};
1278 my $fast = $pconf->{fast};
1279 my $overlap = $pconf->{overlap};
1280 my $other_opts = $pconf->{other_opts};
1281
1282 my $pfam = $execpaths{$exec};
1283 my $parse_pfam = $parsers{$exec};
1284 my $orffile = "$infile.glimmer.orfs";
1285 my @outfiles;
1286 my @tabfile;
1287
1288 # exit if the orffile is not there
1289 unless (-s "$out/$orffile")
1290 {
1291 print "No orfs found - cannot run Pfam. Skipping...\n";
1292 return;
1293 }
1294
1295 # the "overlap" and "fast" options are
1296 # on or off, and should be set by buttons
1297 # on the GUI. I'll leave the rest for
1298 # "other_opts"
1299 my $fastyn = "";
1300 if ($fast == 1)
1301 {
1302 $fastyn = "--fast";
1303 }
1304 my $overlapyn = "";
1305 if ($overlap == 1)
1306 {
1307 $overlapyn = "--overlap";
1308 }
1309
1310 # if the database does not exist, then there's no point carrying on
1311 my @pfams = glob "$db/Pfam-*";
1312 unless (@pfams)
1313 {
1314 print "No Pfam database found, skipping scan of $infile...\n";
1315 return;
1316 }
1317
1318 # get orfs
1319 open (ORFS, "<$out/$orffile") or warn "Can't read orfs from $orffile: $!";
1320 my @olines = <ORFS>;
1321 close ORFS;
1322
1323 # put each orf into an array
1324 my (%orfs,@transfiles);
1325 foreach my $line (@olines)
1326 {
1327 my ($name,$start,$stop) = split(/\s+/, $line);
1328 $orfs{$start} = $stop;
1329 }
1330
1331 # open seq
1332 my $seqobj = Bio::SeqIO->new(-file => "$out/$infile", -format=>"FASTA");
1333 while (my $seq = $seqobj->next_seq())
1334 {
1335 foreach my $start (keys %orfs)
1336 {
1337 # generate an AA translation for each orf
1338 my $stop = $orfs{$start};
1339 my ($transfile,$outfile,$tabfile,$stdoutfile,$subseq,$protseq);
1340 if ($start < $stop)
1341 {
1342 $transfile = "$infile.$start-$stop.trans";
1343 $subseq = $seq->trunc($start,$stop);
1344 $protseq = $subseq->translate();
1345 }
1346 elsif ($start > $stop)
1347 {
1348 $transfile = "$infile.$start.trans";
1349 $subseq = $seq->trunc($stop,$start);
1350 $protseq = $subseq->translate();
1351 }
1352 else
1353 {
1354 print "Something has gone horribly wrong.\n";
1355 next;
1356 }
1357
1358 # print it out to the translation
1359 open (OUT, ">$out/$transfile") or exit "Can't write AA translation: $!";
1360 print OUT "> $transfile\n";
1361 print OUT $protseq->seq();
1362 push (@transfiles, $transfile);
1363 }
1364 }
1365 close OUT;
1366
1367 # run pfam on the local database, using the translated file
1368 foreach my $tf (@transfiles)
1369 {
1370 my $outfile = $tf;
1371 my $tabfile = $tf;
1372 my $stdoutfile = $tf;
1373 $outfile =~ s/trans/pfam/;
1374 $tabfile =~ s/trans/pfam.tab/;
1375 $stdoutfile =~ s/trans/pfam.stdout/;
1376 print "Running Pfam scan on $tf...\n";
1377
1378 if (system("cd $out; $pfam -d $db -o $outfile $fastyn $overlapyn $other_opts $tf > $stdoutfile 2>&1") == 0)
1379 {
1380 # it worked
1381 print "Pfam scan complete.\n";
1382 # empty output file if no hits found
1383 if (-z "$out/$outfile")
1384 {
1385 print "No Pfam hits found.\n";
1386 unlink "$out/$outfile";
1387 unlink "$out/$stdoutfile";
1388 next;
1389 }
1390 }
1391 else
1392 {
1393 print "Pfam scan failed! $!";
1394 next;
1395 }
1396
1397 # parse the pfam output
1398 eval {
1399 if (system("cd $out; $parse_pfam $outfile $tabfile") == 0)
1400 {
1401 print "Parsing Pfam output...\n";
1402 push(@outfiles, $tabfile);
1403 }
1404 else
1405 {
1406 print "Could not parse Pfam! $!";
1407 return;
1408 } };
1409
1410 # finish
1411 unlink "$out/$tf" if (-e "$out/$tf");
1412 unlink "$out/$outfile" if (-e "$out/$outfile");
1413 }
1414 # concatenate all tab files into one big one...
1415 # some people are never satisfied.
1416 my $concat = "$out/$infile.pfam.tab";
1417 open (TAB, ">$concat") or die "Can't concatenate pfam tab files: $!";
1418 foreach my $tab (@outfiles)
1419 {
1420 print "OUT: $tab\n";
1421 open (SMALL, "<$out/$tab") or die "Can't open $tab: $!";
1422 while (my $line = <SMALL>)
1423 {
1424 print TAB $line;
1425 }
1426 close SMALL;
1427 unlink "$out/$tab";
1428 }
1429 close TAB;
1430 push (@tabfile, $concat);
1431 return \@tabfile;
1432 }
1433 # TRANSTERM
1434 sub run_transterm
1435 {
1436 # N.B. TransTerm is a bit dodgy, and may die if there is no space
1437 # between > and the seq. identifier in the FASTA header...
1438 # this is supposed to be fixed, according to the developer, but
1439 # it still seems not to work. This code has therefore been hacked
1440 # to get the code to produce a result. For it to work there
1441 # MUST NOT be the space, as mentioned above.
1442 # Please fix this as soon as transterm can be made to behave!
1443
1444 # get the config details
1445 my $incoming = shift;
1446 my @parts = split(/\|/, $incoming);
1447 my $infile = $parts[0];
1448 my $exec = $parts[1];
1449 my $out = $parts[2];
1450 my $transterm = $execpaths{$exec};
1451 my $parse_transterm = $parsers{$exec};
1452 my $tconf = $config->param(-block=>'TRANSTERM');
1453 my $version = $tconf->{version};
1454 my $other_opts = $tconf->{other_opts} || "";
1455 my $confidence = "";;
1456 my $expterm = "/usr/local/bioinf/transterm/transterm/expterm.dat";
1457
1458 # use v.2 confidence if available
1459 if ( -e $expterm && $version == 2)
1460 {
1461 $confidence = "-r $expterm";
1462 }
1463
1464 # abort here if there is no output from glimmer
1465 my $orffile = "$infile.glimmer.orfs";
1466
1467 # exit if the orffile is not there
1468 unless (-e "$out/$orffile")
1469 {
1470 print "No orfs found - cannot run TransTerm. Skipping...\n";
1471 return;
1472 }
1473
1474 # outfiles
1475 my $outfile = "$infile.transterm.out";
1476 my $stdoutfile = "$infile.transterm.stdout";
1477 my $tabfile = "$infile.transterm.tab";
1478 my $coordfile = "$infile.crd";
1479
1480 # a coordfile will have to be fabricated from the
1481 # orffile in order to make transterm work
1482 open (ORF,"<$out/$orffile") or warn "Can't open $orffile: $!";
1483 my @orfinfo = <ORF>;
1484 close ORF;
1485 open (CRD, ">$out/$coordfile") or warn "Can't open $coordfile: $!";
1486 foreach my $line (@orfinfo)
1487 {
1488 chomp($line);
1489 my @items = split(/\s+/, $line);
1490 # the name of the file should really be added to this
1491 # array, but it seems to break transterm. It has therefore
1492 # been omitted for now. It should be added when more info.
1493 # on making transterm work can be determined.
1494 #push(@items, $infile);
1495 print CRD join("\t", @items), "\n";
1496 }
1497 close CRD;
1498
1499 my @outfiles;
1500
1501 # command line
1502 my $continue = 1;
1503 print "Running TransTerm on $infile...\n";
1504 unless (system("cd $out; $transterm $other_opts $confidence $infile $coordfile > $outfile 2> $stdoutfile") == 0)
1505 {
1506 warn "Could not run TransTerm";
1507 $continue = 0;
1508 }
1509 return unless ($continue == 1);
1510 unless (-s "$out/$outfile")
1511 {
1512 print "No TransTerm output!\n";
1513 $continue = 0;
1514 }
1515 return unless ($continue == 1);
1516 if (system("cd $out; $parse_transterm $outfile $tabfile 2>> $stdoutfile") == 0)
1517 {
1518 print "TransTerm finished!\n";
1519 push (@outfiles,$tabfile);
1520 }
1521 else
1522 {
1523 warn "Could not parse TransTerm output: $!";
1524 }
1525 unlink("$outfile");
1526 return \@outfiles;
1527 }
1528
1529 __END__