python38

作者: rong酱 | 来源:发表于2023-01-11 14:04 被阅读0次
#!/usr/bin/env python
##coding=utf-8

import re
import os
import sys
import argparse
import gzip

parser = argparse.ArgumentParser(description="pipeline")
parser.add_argument('-i', '--input', help = 'the pathway of the input fastq file ', required = True)
parser.add_argument('-id', '--input_id', help = 'the pathway of the input id file ', required = True)
parser.add_argument('-o', '--output', help = 'the pathway of the output vcf file,filter vcf', required = True)
argv = vars(parser.parse_args())
ifile = os.path.abspath(argv['input'].strip())
ofile = os.path.abspath(argv['output'].strip())
idf = os.path.abspath(argv['input_id'].strip())

def creatlist(inputfile):
    idlist=[]
    with open(inputfile,'rb') as v:
        for vi in v:
            vic = vi.strip().split('\n')
            idlist.append(str(vic[0]))
    return idlist

def trimfq(inputfile,outfile,idList):
    oc=open(outfile,'w')
    with gzip.open(inputfile,'rb') as v:
        i=0
        idn=-1
        for vi in v:
            i=i+1
            vic = vi.strip().split('\n')
            vicon=vic[0]
            if str(vicon).startswith('@'):
                vcid=str(vicon).replace('@','')
                if vcid in idList:
                    print("vcid : "+str(vcid))
                    idn=i
                    idr=vcid
            elif int(i)==idn+1:
                idseq=str(vicon)
                oc.write(">"+str(idr)+"\n"+str(idseq)+"\n")
    oc.close

idL=creatlist(idf)
trimfq(ifile,ofile,idL)

相关文章

  • python38

  • python38

  • 安装CPU-pytorch-win10

    conda create -n python38 pip python=3.8conda install anac...

  • IDA keypatch 不能使用的解决办法

    Edit 下没有 keypatch 选项,但是 IDA\python38\Lib\site-packages 目录...

  • linux python安装及安装虚拟环境

    一.安装python 这里给出了可选择安装的python版本,python2,python36,python38,...

  • Conda用法(Linux)

    Conda的环境管理 创建环境 创建一个名为python38的环境,指定Python版本是3.8(不用管是3.8....

  • python常用命令

    因为本机安装了多个版本的Python,常使用Python3.8版本 查看已安装的库 python38 -m -m ...

  • 安装ride环境

    安装ride环境 1.首先安装python,网上有很多教程搜一下 本次安装Python38,环境变量里配置:C:\...

  • 安装ride

    安装ride环境 1.首先安装python,网上有很多教程搜一下 本次安装Python38,环境变量里配置:C:\...

  • Python38 传递函数的参数

    把函数作为其他函数的参数 像使用变量一样使用这个函数 #定义一个求平方的函数 def squares(x): re...

网友评论

      本文标题:python38

      本文链接:https://www.haomeiwen.com/subject/cfwbcdtx.html