文件格式是如下,就是SRA编号,一行一个SRA。fastq文件是在ncbi上下载的SRA格式。小麦基因组单条染色体往往大于500Mb,所以要使用part版本的。mapping使用的bwa mem,call variantion使用的是sentieon
SRR5873706
SRR5873707
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'wheatomics'
import subprocess
with open('dna_input.txt', 'r') as f:
sra_input = ''
ref_fasta = '/data2/Fshare/FastaAndIndex/IWGSC_v1.0_bwa/161010_Chinese_Spring_v1.0_pseudomolecules_parts.fasta'
sample = 'mutant'
for line in f:
sra = line.strip().split()[0]
print sra + '.sra'
# sra to fastq.gz
proc = subprocess.Popen(['fastq-dump', '--split-3', '--helicos', '--gzip', sra + '.sra'], shell=False)
proc.wait()
# Mapping each set of input fastq with BWA-MEM, sorting
proc = subprocess.Popen('bwa mem -M -R \'@RG\tID:' + sra + '\tSM:' + sample + '\tPL:ILLUMINA\'' +
' -t 12 -K 10000000 ' + ref_fasta + ' ' + sra.split('.')[0] + '_1.fastq.gz' + ' ' + sra.split('.')[0] + '_2.fastq.gz' +
' | ' + 'sentieon util sort -r ' + ref_fasta + ' -o ' + sra + 'sorted.bam' + ' -t 10 --sam2bam -i -', shell=True)
proc.wait()
# delete all the fastq.gz
proc = subprocess.Popen(['shred', '-u', '-z', sra.split('.')[0] + '_1.fastq.gz'], shell=False)
proc.wait()
proc = subprocess.Popen(['shred', '-u', '-z', sra.split('.')[0] + '_2.fastq.gz'], shell=False)
proc.wait()
# get all bam file and put them into next step
sra_input = sra_input + ' -i ' + sra + 'sorted.bam'
proc.wait()
print sra_input
# Remove Duplicate Reads on the multiple sorted BAM files
proc = subprocess.Popen(['sentieon', 'driver', '-t', '10', sra_input, '--algo', 'LocusCollector', '--fun', 'score_info', 'score.txt'], shell= False)
proc.wait()
proc = subprocess.Popen(['sentieon', 'driver', '-t', '10', sra_input, '--algo', 'Dedup', '--rmdup', '--score_info',
'score.txt', '--metrics', 'dedup_metrics.txt', 'deduped.bam'], shell=False)
proc.wait()
# Indel realigner
proc = subprocess.Popen(['sentieon', 'driver', '-r', ref_fasta, '-t', '10', '-i', 'deduped.bam', '--algo', 'Realigner',
'realigned.bam'], shell=False)
proc.wait()
# Base recalibration
proc = subprocess.Popen(['shred', '-u', '-z', 'deduped.bam'], shell=False)
proc.wait()
proc = subprocess.Popen(['sentieon', 'driver', '-r', ref_fasta, '-t', '10', '-i', 'realigned.bam', '--algo',
'QualCal', 'recal_data.table'], shell=False)
proc.wait()
proc = subprocess.Popen(['sentieon', 'driver', '-r', ref_fasta, '-t', '10', '-i', 'realigned.bam', '-q',
'recal_data.table', '--algo', 'QualCal', 'recal_data.table.post'], shell=False)
proc.wait()
proc = subprocess.Popen(['sentieon', 'driver', '-t', '10', '--algo', 'QualCal', '--plot', '--before',
'recal_data.table', '--after', 'recal_data.table.post', 'recal.csv'], shell= False)
proc.wait()
proc = subprocess.Popen(['sentieon', 'plot', 'bqsr', '-o', 'recal_plots.pdf', 'recal.csv'], shell=False)
proc.wait()
# HC Variant caller
proc = subprocess.Popen(['sentieon', 'driver', '-r', ref_fasta, '-t', '10', '-i', 'realigned.bam', '-q',
'recal_data.table', '--algo', 'Haplotyper', '--emit_mode', 'gvcf', '--emit_conf',
'10', '--call_conf', '30', sample + '-hc.g.vcf.gz'], shell=False)
proc.wait()
proc = subprocess.Popen(['shred', '-u', '-z', 'realigned.bam'], shell=False)
proc.wait()
——————————————————————————————
欢迎关注“小麦生信联盟”