def genome_align(args): """ Use Bowtie2 to map reads to representative genomes """ # Bowtie2 bam_path = os.path.join(args['outdir'], 'snps/temp/genomes.bam') command = '%s --no-unal ' % args['bowtie2'] command += '-x %s ' % '/'.join([args['outdir'], 'snps/temp/genomes' ]) # index if args['max_reads']: command += '-u %s ' % args['max_reads'] # max num of reads if args['trim']: command += '--trim3 %s ' % args['trim'] # trim 3' command += '--%s ' % args['speed'] # speed/sensitivity command += '--threads %s ' % args['threads'] # threads command += '-f ' if args['file_type'] == 'fasta' else '-q ' # input type command += '-1 %s -2 %s ' % ( args['m1'], args['m2']) if args['m2'] else '-U %s ' % args['m1'] # input reads # Pipe to samtools command += '| %s view -b - ' % args['samtools'] # convert to bam command += '| %s sort -f - %s ' % (args['samtools'], bam_path) # sort bam # Run command args['log'].write('command: ' + command + '\n') process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Check for errors utility.check_exit_code(process, command) print(" finished aligning") print(" checking bamfile integrity") utility.check_bamfile(args, bam_path)
def genome_align(args): """ Use Bowtie2 to map reads to representative genomes from each genome cluster """ # Build command # bowtie2 command = '%s --no-unal ' % args['bowtie2'] # index command += '-x %s ' % '/'.join([args['outdir'], 'snps/temp/genomes']) # specify reads if args['max_reads']: command += '-u %s ' % args['max_reads'] # trim reads if args['trim']: command += '--trim3 %s ' % args['trim'] # speed/sensitivity command += '--%s ' % args['speed'] # threads command += '--threads %s ' % args['threads'] # file type if args['file_type'] == 'fasta': command += '-f ' else: command += '-q ' # input file if (args['m1'] and args['m2']): command += '-1 %s -2 %s ' % (args['m1'], args['m2']) else: command += '-U %s' % args['m1'] # convert to bam command += '| %s view -b - ' % args['samtools'] # sort bam bam_path = os.path.join(args['outdir'], 'snps/temp/genomes.bam') command += '| %s sort -f - %s ' % (args['samtools'], bam_path) # Run command args['log'].write('command: '+command+'\n') process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Check for errors utility.check_exit_code(process, command) utility.check_bamfile(args, bam_path)
def pangenome_align(args): """ Use Bowtie2 to map reads to all specified genome species """ # Build command command = '%s --no-unal ' % args['bowtie2'] # index command += '-x %s ' % '/'.join([args['outdir'], 'genes/temp/pangenomes']) # specify reads if args['max_reads']: command += '-u %s ' % args['max_reads'] # trim reads if args['trim']: command += '--trim3 %s ' % args['trim'] # speed/sensitivity command += '--%s-local ' % args['speed'] # threads command += '--threads %s ' % args['threads'] # file type if args['file_type'] == 'fasta': command += '-f ' else: command += '-q ' # input file if (args['m1'] and args['m2']): command += '-1 %s -2 %s ' % (args['m1'], args['m2']) else: command += '-U %s ' % args['m1'] # output unsorted bam bampath = '/'.join([args['outdir'], 'genes/temp/pangenomes.bam']) command += '| %s view -b - > %s' % (args['samtools'], bampath) # Run command args['log'].write('command: '+command+'\n') process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Check for errors utility.check_exit_code(process, command) print(" finished aligning") print(" checking bamfile integrity") utility.check_bamfile(args, bampath)
def pangenome_align(args): """ Use Bowtie2 to map reads to all specified genome clusters """ # Build command command = '%s --no-unal ' % args['bowtie2'] # index command += '-x %s ' % '/'.join([args['outdir'], 'genes/temp/pangenomes']) # specify reads if args['max_reads']: command += '-u %s ' % args['max_reads'] # trim reads if args['trim']: command += '--trim3 %s ' % args['trim'] # speed/sensitivity command += '--%s-local ' % args['speed'] # threads command += '--threads %s ' % args['threads'] # file type if args['file_type'] == 'fasta': command += '-f ' else: command += '-q ' # input file if (args['m1'] and args['m2']): command += '-1 %s -2 %s ' % (args['m1'], args['m2']) else: command += '-U %s' % args['m1'] # output unsorted bam bampath = '/'.join([args['outdir'], 'genes/temp/pangenome.bam']) command += '| %s view -b - > %s' % (args['samtools'], bampath) # Run command args['log'].write('command: '+command+'\n') process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Check for errors utility.check_exit_code(process, command) utility.check_bamfile(args, bampath)
def genome_align(args): """ Use Bowtie2 to map reads to representative genomes """ # Bowtie2 bam_path = os.path.join(args['outdir'], 'snps/temp/genomes.bam') command = '%s --no-unal ' % args['bowtie2'] if args['bowtie-db']: command += '-x %s ' % '/'.join([args['bowtie-db'], 'genomes']) # index else: command += '-x %s ' % '/'.join([args['outdir'], 'snps/temp/genomes' ]) # index if args['max_reads']: command += '-u %s ' % args['max_reads'] # max num of reads if args['trim']: command += '--trim3 %s ' % args['trim'] # trim 3' command += '--%s' % args['speed'] # alignment speed command += '-local ' if args[ 'mode'] == 'local' else ' ' # global/local alignment command += '--threads %s ' % args['threads'] command += '-f ' if args['file_type'] == 'fasta' else '-q ' # input type if args['m2']: # -1 and -2 contain paired reads command += '-1 %s -2 %s ' % (args['m1'], args['m2']) elif args['interleaved']: # -1 contains paired reads command += '--interleaved %s ' % args['m1'] else: # -1 contains unpaired reads command += '-U %s ' % args['m1'] # Pipe to samtools command += '| %s view -b - ' % args['samtools'] # convert to bam command += '--threads %s ' % args['threads'] command += '| %s sort - ' % args['samtools'] command += '--threads %s ' % args['threads'] command += '-o %s ' % bam_path # Run command args['log'].write('command: ' + command + '\n') process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Check for errors utility.check_exit_code(process, command) print(" finished aligning") print(" checking bamfile integrity") utility.check_bamfile(args, bam_path)