fastp+bowtie2+samtools+bcftools檢測(cè)snp的流程

這個(gè)是單端測(cè)序數(shù)據(jù)

#configfile: "singleconfig.yaml"
workdir: "/home/myan/scratch/private/practice_data/popgenomics/rubi.gbs"

SRR, = glob_wildcards("00.raw.fq.single/" + "{srr}.fastq.gz")

print(SRR)

rule all:
    input:
        #expand("01.fastp.filtered.single/" + "{srr}_clean.fastq.gz",srr=SRR),
        #"reference/genome_index/Pr.1.bt2",
        #expand("02.sam/" + "{srr}.sam",srr=SRR),
        #expand("02.sorted.bam/" + "{srr}.sorted.bam.bai",srr=SRR),
        "03.bcf/" + "raw.vcf"


rule a_runfastp:
    input:
        read01 = "00.raw.fq.single/" + "{srr}.fastq.gz"
    output:
        read01 = "01.fastp.filtered.single/" + "{srr}_clean.fastq.gz",
        json = "01.fastp.report.single/" + "{srr}.json",
        html = "01.fastp.report.single/" + "{srr}.html"
    threads:
        8
    params:
        "-f 10"
    shell:
        """
        fastp -i {input.read01} -o {output.read01} {params} \
        -w {threads} -j {output.json} -h {output.html}
        """

rule b_bowtie2index:
    input:
        ref = "reference/genome/Pr.fna"
    output:
        index = "reference/genome_index/Pr.1.bt2"
    params:
        "reference/genome_index/Pr"
    threads:
        8
    shell:
        """
        bowtie2-build {input.ref} {params}
        """

rule c_bowtie2align:
    input:
        read01 = rules.a_runfastp.output.read01
    output:
        sam = "02.sam/" + "{srr}.sam"
    threads:
        8
    params:
        index = "reference/genome_index/Pr",
        others = "-q --very-sensitive --no-unal --local --rg-id {srr} --rg SM:{srr}"
    shell:
        """
        bowtie2 -x {params.index} -U {input.read01} -S {output.sam} {params.others} -p {threads}
        """

rule d_samtoolsview:
    input:
        sam = rules.c_bowtie2align.output.sam
    output:
        bam = "02.bam/" + "{srr}.bam"
    threads:
        2
    shell:
        """
        samtools view -@ {threads} -bS -o {output.bam} {input.sam}
        """

rule e_samtoolssort:
    input:
        bam = rules.d_samtoolsview.output.bam
    output:
        sorted = "02.sorted.bam/" + "{srr}.sorted.bam"
    threads:
        2
    shell:
        """
        samtools sort -@ {threads} -O bam {input.bam} -o {output.sorted}
        """

rule f_samtoolsindex:
    input:
        sorted = rules.e_samtoolssort.output.sorted
    output:
        bai = "02.sorted.bam/" + "{srr}.sorted.bam.bai"
    threads:
        2
    shell:
        """
        samtools index {input.sorted}
        """

rule g_bcftools:
    input:
        bam = expand("02.sorted.bam/" + "{srr}.sorted.bam",srr=SRR),
        ref = 'reference/genome/Pr.fna'
    output:
        vcf = "03.bcf/" + "raw.vcf"
    threads:
        8
    shell:
        """
        bcftools mpileup -O b -f {input.ref} --threads 8 -q 20 \
        -Q 30 {input.bam} | bcftools call --ploidy 2 -m -v -o {output.vcf} --threads 8
        """
    

雙端測(cè)序數(shù)據(jù)只需要把fastp和bowtie2的內(nèi)容改為

#configfile: "singleconfig.yaml"
workdir: "/home/myan/scratch/private/practice_data/popgenomics/rubi.gbs"

SRR,FRR = glob_wildcards("00.raw.fq.paired/" + "{srr}_{frr}.fastq.gz")

print(SRR)

rule all:
    input:
        #expand("01.fastp.filtered.single/" + "{srr}_clean.fastq.gz",srr=SRR),
        #"reference/genome_index/Pr.1.bt2",
        #expand("02.sam/" + "{srr}.sam",srr=SRR),
        expand("02.sorted.bam/" + "{srr}.sorted.bam.bai",srr=SRR)


rule a_runfastp:
    input:
        read01 = "00.raw.fq.paired/" + "{srr}_1.fastq.gz",
        read02 = "00.raw.fq.paired/" + "{srr}_2.fastq.gz"
    output:
        read01 = "01.fastp.filtered.paired/" + "{srr}_clean_1.fastq.gz",
        read02 = "01.fastp.filtered.paired/" + "{srr}_clean_2.fastq.gz",
        json = "01.fastp.report.paired/" + "{srr}.json",
        html = "01.fastp.report.paired/" + "{srr}.html"
    threads:
        8
    params:
        "-f 10"
    shell:
        """
        fastp -i {input.read01} -I {input.read02} -o {output.read01} -O {output.read02} \
        {params} -w {threads} -j {output.json} -h {output.html}
        """

rule b_bowtie2index:
    input:
        ref = "reference/genome/Pr.fna"
    output:
        index = "reference/genome_index/Pr.1.bt2"
    params:
        "reference/genome_index/Pr"
    threads:
        8
    shell:
        """
        bowtie2-build {input.ref} {params}
        """

rule c_bowtie2align:
    input:
        read01 = rules.a_runfastp.output.read01,
        read02 = rules.a_runfastp.output.read02
    output:
        sam = "02.sam/" + "{srr}.sam"
    threads:
        8
    params:
        index = "reference/genome_index/Pr",
        others = "-q --very-sensitive --no-unal --local --rg-id {srr} --rg SM:{srr}"
    shell:
        """
        bowtie2 -x {params.index} -1 {input.read01} -2 {input.read02} -S {output.sam} {params.others} -p {threads}
        """

bcftools的命令 參考 https://www.youtube.com/watch?v=mKqdfdtv0cI

http://samtools.github.io/bcftools/howtos/variant-calling.html

歡迎大家關(guān)注我的公眾號(hào)

小明的數(shù)據(jù)分析筆記本

小明的數(shù)據(jù)分析筆記本 公眾號(hào) 主要分享:1、R語(yǔ)言和python做數(shù)據(jù)分析和數(shù)據(jù)可視化的簡(jiǎn)單小例子;2、園藝植物相關(guān)轉(zhuǎn)錄組學(xué)、基因組學(xué)、群體遺傳學(xué)文獻(xiàn)閱讀筆記;3、生物信息學(xué)入門(mén)學(xué)習(xí)資料及自己的學(xué)習(xí)筆記!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容