#!/usr/bin/perl -w # # cure_cycle_split.pl # A simple Wrapper script to perform n cycles of reference sequence "curing", calling the script cure_refseqs.pl # # Janet.Higgins@bbsrc.ac.uk,17/2/2011 # Script requires the naive reference sequence in both fasta and bfa format, together with the reads # in bfq format obtained from a diploid progenitor of the polyploid genome. # The reads have been split into two parts,each containing 40bp reads to improve alignment efficiency. # mapmerge is used to merge the maps from the two sets of reads. # It assumes the MAQ program is in the user's path. # The default number of cycles in four, in our application we found six cycles were required. unless (@ARGV >= 4) { print "Usage: cure_cycle_split.pl \n"; exit; } my $cycles = $ARGV[4] || 4; # Open a log file for combined STDOUT/STDERR from Maq my $logfile = "curing.$$.log"; # We have to allow file clobbering, simply on disc space grounds # First we copy the original refseq files so that they can be clobbered safely system ("cp $ARGV[0] current.fa"); system ("cp $ARGV[1] current.bfa"); for my $i (1 .. $cycles) { print "Starting curing cycle $i/$cycles ...\n"; print "Mapping ($i/$cycles cycles)... \n"; system ("maq map current1.map current.bfa $ARGV[2] >> $logfile 2>&1 "); system ("maq map current2.map current.bfa $ARGV[3] >> $logfile 2>&1 "); print "Merging maps ($i/$cycles cycles)... \n"; system ("maq mapmerge current.map current1.map current2.map >> $logfile 2>&1"); print "Assembling consensus ($i/$cycles cycles)... \n"; system ("maq assemble current.cns current.bfa current.map >> $logfile 2>&1"); print "Extracting consensus ($i/$cycles cycles)... \n"; system("maq cns2fq current.cns > current.cns.fastq"); print "Refseq curing ($i/$cycles cycles)... \n"; system ("cure_refseqs.pl current.fa current.cns.fastq cured.fa"); print "Converting cured refseq ($i/$cycles cycles)... \n"; system ("maq fasta2bfa cured.fa cured.bfa"); print "Rotating files ($i/$cycles cycles)\n"; system ("mv cured.fa current.fa"); system ("mv cured.bfa current.bfa"); } # Extract salient details from logfile, print to STDOUT and then delete print "\nMapping efficiencies over curing cycles\n"; open (LOG, "<$logfile") or die "Couldn't open logfile for parsing ($!)\n"; while () { if (/^\[match_data2/ || /^-- \(total/) { print $_; } } unlink $logfile;