#!/usr/bin/env perl

use strict;
use warnings;

print '#!/bin/bash', "\n\n";

while (my $input = <>) { 
    chomp $input;
    if ( $input =~ /\A raw \/ (CS004_NoIndex_L002_R12_\d+)\.fastq \z/xms ) { 
        my $stem = $1;
        print "    retroname_fastq_reads.pl jumbled/$stem.jumb.filt1.neo_n.fq > jumbled/$stem.jumb.filt1.paleo_n.fq ;\n";
        print "    bowtie contams/Ecoli_OP50 -p 8 -k 11 -v 2 --best -m 10 -t --strata", 
              " --un jumbled/$stem.jumb.filt2.paleo_n.fq jumbled/$stem.jumb.filt1.paleo_n.fq /dev/null ;\n",
              ;
        print "    bowtie contams/CelMt      -p 8 -k 11 -v 2 --best -m 10 -t --strata",
              " --un jumbled/$stem.jumb.filt3.paleo_n.fq jumbled/$stem.jumb.filt2.paleo_n.fq /dev/null ;\n",
              ;
        print "    paired_vs_unp_fastq.or.a.pl --fastq --r1 \"#0\/1\" --r2 \"#0\/2\"", 
              " -i jumbled/$stem.jumb.filt3.paleo_n.fq -p paired/$stem.pe.filt3.paleo_n.fq -u unpaired/$stem.se.filt3.paleo_n.fq ;\n",
              ;
        print "\n";
    }
    else {
        die "Can't parse input: $input\n";
   }
}

print "    program_done_e-ping.pl -p Csp9_read_filt_sort_10apr2012 ;\n\n";

