#!/usr/bin/env perl # Perl wrapper script for rose. # # # # Jan Krueger use File::Basename; %rose_config; foreach $m (split("##",join(' ',@ARGV))) { $m =~ s/^\s+//; $m =~ s/\s+$//; ($k,$v) = split(" *= *",$m); $rose_config{$k} = $v if $k; } # add default parameter depending on InputType if ($rose_config{InputType} == 4) { # DNA $rose_config{TheAlphabet} = "\"ACGT\""; if (!$rose_config{TheDNAmodel} || $rose_config{TheDNAmodel} eq "None") { delete $rose_config{TheDNAModel}; $rose_config{ThePAMMatrix} = "[". "[.97,.01,.01,.01],". "[.01,.97,.01,.01],". "[.01,.01,.97,.01],". "[.01,.01,.01,.97]]"; } $rose_config{TheFreq} = "[.25,.25,.25,.25]"; } elsif ($rose_config{InputType} == 20) { #AMINOACID $rose_config{TheAlphabet} = "\"ARNDCQEGHILKMFPSTWYV\""; $rose_config{ThePAMMatrix} = "[". "[9867.0, 2.0, 9.0, 10.0, 3.0, 8.0, 17.0, 21.0, 2.0, 6.0, 4.0, 2.0, 6.0, 2.0, 22.0, 35.0, 32.0, 0.0, 2.0, 18.0],". "[ 1.0,9913.0, 1.0, 0.0, 1.0, 10.0, 0.0, 0.0, 10.0, 3.0, 1.0, 19.0, 4.0, 1.0, 4.0, 6.0, 1.0, 8.0, 0.0, 1.0],". "[ 4.0, 1.0,9822.0, 36.0, 0.0, 4.0, 6.0, 6.0, 21.0, 3.0, 1.0, 13.0, 0.0, 1.0, 2.0, 20.0, 9.0, 1.0, 4.0, 1.0],". "[ 6.0, 0.0, 42.0,9859.0, 0.0, 6.0, 53.0, 6.0, 4.0, 1.0, 0.0, 3.0, 0.0, 0.0, 1.0, 5.0, 3.0, 0.0, 0.0, 1.0],". "[ 1.0, 1.0, 0.0, 0.0,9973.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 5.0, 1.0, 0.0, 3.0, 2.0],". "[ 3.0, 9.0, 4.0, 5.0, 0.0,9876.0, 27.0, 1.0, 23.0, 1.0, 3.0,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, 2.0, 2.0, 1.0, 7.0, 4.0, 3.0, 17.0,9840.0, 38.0, 5.0, 2.0, 2.0],". "[ 22.0, 2.0, 13.0, 4.0, 1.0, 3.0, 2.0, 2.0, 1.0, 11.0, 2.0, 8.0, 6.0, 1.0, 5.0, 32.0,9871.0, 0.0, 2.0, 9.0],". "[ 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0,9976.0, 1.0, 0.0],". "[ 1.0, 0.0, 3.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 1.0, 1.0, 0.0, 0.0, 21.0, 0.0, 1.0, 1.0, 2.0,9945.0, 1.0],". "[ 13.0, 2.0, 1.0, 1.0, 3.0, 2.0, 2.0, 3.0, 3.0, 57.0, 11.0, 1.0, 17.0, 1.0, 3.0, 2.0, 10.0, 0.0, 2.0,9901.0]". "]"; $rose_config{TheFreq} = "[.087,.041,.040,.047,.033,.038,.050,.089,.034,.037,.085,.081,.015,.040,.051,.070,.058,.010,.030,.065]"; } else { die "Unknown or Unset InputType parameter!"; } # add general defaults $rose_config{AlignmentFormat} = "\"FASTA\""; #surround String Types with quotations if ($rose_config{TheSequence}) { $rose_config{TheSequence} = "\"".$rose_config{TheSequence}."\""; } if ($rose_config{TheDNAmodel}) { $rose_config{TheDNAmodel} = "\"".$rose_config{TheDNAmodel}."\""; } # write config to current working dir open (FH,"> rose.config") or die "$!"; for $k (keys(%rose_config)) { print FH "$k = $rose_config{$k} \n"; } close(FH); # call rose with generated config and split output into 3 files open ($ROSESEQ, ">rose.fas") or die "$!"; open ($ROSETREE, ">rose.phy") or die "$!"; $basedir = dirname($0); open (ROSE,"$basedir/rose.bin rose.config|") or die "$!"; while () { chomp($_); if (/^Sequences:/) { $FH = $ROSESEQ; } elsif (/^Alignment:/) { $FH = STDOUT; } elsif (/^PHYLIP tree:/) { $FH = $ROSETREE; } else { print $FH $_,"\n" if $_; } } close(ROSE); close($ROSESEQ); close($ROSETREE);