我正在构建一系列脚本,这些脚本将通过基因测序仪有效地运行我所有的水污染样品(它们是我的输入文件),并将这些输入文件与另一个参考文件目录进行比较。它将被吐出到匹配和不匹配的输出目录中。任何帮助将不胜感激。
我不知道如何编写此脚本。我是python的新手。
尽管,我已经有3个拼图中的2个。第一,理论上将为此脚本中的命令设置默认的bbduk值。或者,如果您想运行其他值,则可以自由地再次调用该bbduk值(和/或只是更改它)。第二个脚本将为命令提供更多结构,在某种程度上充当命令的主干。
from water_contamination.lib.bbduk import build_command
def main(*args, **kwargs):
#import pdb; pdb.set_trace()
import argparse
parser=argparse.ArgumentParser()
parser.add_argument("-input", type=list, help="fastq1, fastq2 (Coma seperated)")
parser.add_argument("-nonmatching_output", type=list, help="out1 and out2")
parser.add_argument("-matching_output", type=list, help="outm1 and outm2")
parser.add_argument("-references", type=list, help="references, reference (Coma seperated)")
parser.add_argument("-stats", type=list, help="stats")
parser.add_argument("-minavgquality", type=int, default=5, help="choose a minavgquality value or stay with the default of 5")
parser.add_argument("-trimpolya", type=int, default=7, help="choose a trimpolya value or stay with the default of 7")
parser.add_argument("-minilength", type=int, default=51, help="choose a minilength value or stay with the default of 51")
parser.add_argument("-maxns", type=int, default=1, help="choose a maxns value or stay with the default of 1")
parser.add_argument("-k", type=int, default=25, help="choose a k value or stay with the default of 25")
parser.add_argument("-t", type=int, default=2, help="choose a t value or stay with the default of 2")
parser.add_argument("-zl", type=int, default=6, help="choose zl value or stay with the default of 6")
parser.add_argument("-entropy", type=float, default=0.5, help="choose an entropy value or stay with the default of 0.5")
parser.add_argument("-ow", type=str, default="t", help="choose an ow value or stay with the default of t")
args=parser.parse_args()
bbduk_command=build_command(args)
if args.minavgquality:
print("minavgquality={}".format(args.minavgquality))
if args.trimpolya:
print("trimpolya={}".format(args.trimpolya))
if args.minilength:
print("minilength={}".format(args.minilength))
if args.maxns:
print("maxns={}".format(args.maxns))
print(type(args.maxns))
if args.k:
print("k={}".format(args.k))
if args.t:
print("t={}".format(args.t))
if args.zl:
print("zl={}".format(args.zl))
if args.entropy:
print("entropy={}".format(args.entropy))
if args.ow:
print("ow={}".format(args.ow))
def build_input(fastq1, fastq2):
return "in1=" + fastq1 + " in2=" + fastq2
def build_nonmatching_output(fastq1, fastq2):
return "out1=" + fastq1 + " out2=" + fastq2
def build_matching_output(fastq1, fastq2):
return "outm1=" + fastq1 + " outm2=" + fastq2
def build_reference(references):
return "ref=" + ",".join(references)
def build_stats(stats):
return "stats=" + stats
def bulid_minavgquality(minavgquality=5):
return "minavgquality={}".format(minavgquality)
def build_trimpolya(trimpolya=7):
return "trimpolya={}".format(trimpolya)
def build_minilength(minilength=51):
return "minilength={}".format(minilength)
def build_maxns(maxns=1):
return "maxns={}".format(maxns)
def build_k(k=25):
return "k={}".format(k)
def build_t(t=2):
return "t={}".format(t)
def build_zl(zl=6):
return "zl={}".format(zl)
def build_entropy(entropy=0.5):
return "entropy={}".format(entropy)
def build_ow(ow="T"):
return "ow={}".format(ow)
def build_command(args):
string_list=[input, output, reference, stats, minavgquality, trimpolya, minilength, maxns, k, t, zl, entropy, ow]
string_list.append("echo '{}'".format(igm//apps/bbmap/bbmap/bbduk.sh))
input=build_input(args.input)
string_list.append(input)
matching_output=build_matching_output(args.matching_output)
string_list.append(matching_output)
nonmatching_output=build_nonmatching_output(args.nonmatching_output)
string_list.appending(nonmatching_output)
stats=build_stats(args.stats)
string_list.appending(stats)
references=build_references(args.references)
string_list.append(references)
trimpolya=build_trimpolya(args.trimpolya)
string_list.append(trimpolya)
minlength=build_minlength(args.minlength)
string_list.append(minlength)
maxns=build_mans(args.maxns)
string_list.append(maxns)
minavgquality=build_minavgquality(args.minavgquality)
string_list.append(minavgquality)
k=build_k(args.k)
string_list.append(k)
t=build_t(args.t)
string_list.append(t)
zl=build_zl(args.zl)
string_list.append(zl)
ow=build_ow(args.ow)
string_list.append(ow)
entropy=build_entropy(args.entropy)
string_list.append(entropy)
所有这些的预期结果是创建此程序包以允许您附加相应的目录;输入,引用,统计信息,matching_output和nonmatching_output,然后由命令执行其余操作。这将是使用提供的资源来构建命令,并在构建后也运行该命令,并将结果吐出到matching_output和nonmatching_output中。如果您希望我在任何方面进行进一步扩展或重申任何内容,请与我们联系。谢谢。