python 计算 fastq数据中的GC 含量
001、
(base) [b20223040323@admin1 test]$ ls SRR1770413_1.fastq SRR1770413_2.fastq test.py (base) [b20223040323@admin1 test]$ cat test.py #!/bin/env python # -*- coding:utf-8 -*- from Bio import SeqIO fq1 = list(SeqIO.parse("SRR1770413_1.fastq", "fastq")) fq2 = list(SeqIO.parse("SRR1770413_2.fastq", "fastq")) total_gc = 0 total_bases = 0 for i in fq1: i = str(i.seq) total_gc += i.count('G') + i.count('C') + i.count('g') + i.count('c') total_bases += len(i) for i in fq2: i = str(i.seq) total_gc += i.count('G') + i.count('C') + i.count('g') + i.count('c') total_bases += len(i) print("GC_count:" + str(total_gc/total_bases)) (base) [b20223040323@admin1 test]$ python test.py GC_count:0.6710963455149501
。
更正一下,python脚本的解释器写错了,正确的应该为:
#!/usr/bin/env python
# -*- coding: uft-8 -*-
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步