def assemble_paired_end_reads(args, velvet_optimiser, indiv, read, interleaved_dir): assert is_dir(interleaved_dir), IOError("Directory {} containing interleaved reads does not exist".format(interleaved_dir)) singletons = os.path.join( interleaved_dir, "{0}{1}".format(indiv, '-READ-singleton.fastq.gz') ) interleaved = os.path.join( interleaved_dir, "{0}{1}".format(indiv, '-READ1and2-interleaved.fastq.gz') ) for f in [singletons, interleaved]: assert os.path.isfile(f), IOError("Missing sequence file(s): {0}".format(f)) assembly_dir = os.path.join(args.output, indiv, 'assembly') mkdir_p(assembly_dir) os.chdir(assembly_dir) velveth = "-fastq.gz -shortPaired {} -short {}".format(singletons, interleaved) cmd = [velvet_optimiser, "-s", args.s, "-e", args.e, "-c", "'ncon'", "-t", args.t, "-a", "-f", velveth ] stdout, stderr = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() return stdout, stderr, assembly_dir