python分别用while和for于vcf格式提取复等位基因的snp(并计算分别条数)
2017-11-29 09:16
771 查看
line=open('cleanqt.vcf','r').readlines() #use ‘while’
out1=open('alle=1.vcf','w')
out2=open('alle=2.vcf','w')
out3=open('alle=3.vcf','w')
a=0
b=0
c=0
d=0
while a<len(line):
word=line[a].split()
if len(word[4])==3:
out2.write(line[a])
b+=1
elif len(word[4])==5:
out3.write(line[a])
c+=1
else:
out1.write(line[a])
d+=1
a+=1
print(d,b,c)
line=open('cleanqt.vcf','r').readlines() #use ‘for in’
out1=open('alle=1.vcf','w')
out2=open('alle=2.vcf','w')
out3=open('alle=3.vcf','w')
a=0
b=0
c=0
for l in line:
word=str(l).split()
if len(word[4])==3:
out2.write(str(l))
b+=1
elif len(word[4])==5:
out3.write(str(l))
c+=1
else:
out1.write(str(l))
a+=1
print(a,b,c)
out1=open('alle=1.vcf','w')
out2=open('alle=2.vcf','w')
out3=open('alle=3.vcf','w')
a=0
b=0
c=0
d=0
while a<len(line):
word=line[a].split()
if len(word[4])==3:
out2.write(line[a])
b+=1
elif len(word[4])==5:
out3.write(line[a])
c+=1
else:
out1.write(line[a])
d+=1
a+=1
print(d,b,c)
line=open('cleanqt.vcf','r').readlines() #use ‘for in’
out1=open('alle=1.vcf','w')
out2=open('alle=2.vcf','w')
out3=open('alle=3.vcf','w')
a=0
b=0
c=0
for l in line:
word=str(l).split()
if len(word[4])==3:
out2.write(str(l))
b+=1
elif len(word[4])==5:
out3.write(str(l))
c+=1
else:
out1.write(str(l))
a+=1
print(a,b,c)
相关文章推荐
- python 学习之流程控制if for while 及print 格式控制
- C++上机报告 分别用3种循环(while~、for(;;)~、do~while)计算下式
- 编程作业50页3题 分别使用 do-while和 for 循环计算1+1/2!+1/3!+1/4!...+1/20!
- Python——通过while、for、if—else完成一个小程序 学Python的第三天,郑老师让我们写一个计算车费的小程序,还好之前有写小程序的基础,然后很快就完成了,下面是相关内容(^_^)
- 第二周 任务四 分别使用for,while,do-while循环语句计算 n!
- C#--第2周实验--任务四--编写一个控制台应用--分别使用for,while,do-while循环语句计算 n!
- python (if-else ,for, while, break, continue)
- Java:多重循环for、while、do-while(简单判断是否是四位整数、1-100累加,水仙花、最大公约数。最小公倍数、完数、输入任意数计算每位数之和、弹力球问题)
- python之for、while、if练习题
- 3. Python - while 和 for 循环
- Python学习:两种循环语句for和while
- Python-while 计算100以内奇数和
- 提取邮件(eml格式)保存为html-python
- python的for循环和while循环的一些代码
- 09-python_流程控制-for-while
- Python学习笔记--for, while循环后面加else的作用
- python使用递归和动态规划分别计算斐波那契数列
- pysam - 多种格式基因组数据(sam/bam/vcf/bcf/cram/…)读写与处理模块(python)
- Python笔记(四) if,while,for
- PHP的<?php for/foreachswitch/while/if end...?>格式代码