#!/usr/bin/perl #Greetings by developer Rima Upchurch with help from James Henriksen. print "\n"; print "Welcome to PRELIBSHUFF, the formatting program for LIBSHUFF developed by Rima Ann Upchurch.\n"; print "Version 1.0 October 20, 2003\n"; #Specify the phylip file print "What is the phylip file (For example mysequences.phy)? Reminder: You must be in the directory that this file is found.\n"; $phylipfile = ; chomp($phylipfile); #Open file that has the aligned sequences open (INFILE, "$phylipfile") || die "Unable to find file.\n"; @sequences = ; close (INFILE); #Use match to find and s/ to substitute and search and replace ~ with - foreach $line(@sequences) { $line =~ s/~/-/g; } #Rewrite file to contain changes print "Generating an infile for dnadist which will overwrite any file named infile in this directory.\n"; open (INFILE, ">infile"); foreach $line (@sequences) { print INFILE $line; } close(INFILE); #Now specify path to dnadist in Phylip package print ("What is the path to DNADIST? (For example C:\\program files\\dnadist.exe) \n"); $phylip = || die "Unable to find DNADIST.\n"; chomp ($phylip); #Run phylip dnaddist with added quotes to parse spaces in the path name system ("\"$phylip\""); #Formatting the outfile #Put numbers into the array open (OUTFILE, "< outfile") or die "no outfile\n"; @array = ; close (OUTFILE); #Get rid of number at the top splice (@array, 0, 1); #Use match to find and s/ to substitute foreach $line(@array) { #get rid of all new line characters $line =~ s/\n//g; #substitute newline for words at the beginning if ($line =~ /^\S+/) { $line =~ s/^\S+\s+/\n/g; } #substitute double space for tabs $line =~ s/ /\t/g; } #Opps there's one at the beginning we don't want $array[0] =~ s/^\n//g; #Save as sample file for libshuff print "Writing sample.txt to current directory, which will overwrite any file named sample.txt in this directory.\n"; open (SAMPLE, "> sample.txt") or die "no sample file found\n"; foreach $line (@array) { print SAMPLE $line; } close (SAMPLE);