leoric666 发表于 2021-2-15 16:26:00

python 问题麻烦最帅的大神求助

代码一
import re
# Open a sample fastq file for reading
filename = '/scratch/SampleDataFiles/Sample.R1.fastq'
with open(filename, 'r') as read_sample:
    for line in read_sample:
      # get rid the hidden new line character
      line = line.rstrip()
      if re.match('^+$', line):
            # Print the line
            print(line)

代码二
seq = 'GCCGGCCCTCAGACAGGAGTGGTCCTGGATGTGGATG'
kmer_length = 6
kmer_dictionary = {}
stop = len(seq) - kmer_length + 1
aip_kmers = open("newlines1.txt", 'w')
for start in range(0, stop):
    kmer = seq
    if kmer in kmer_dictionary:
      kmer_dictionary += 1
    else:
      kmer_dictionary = 1
t = "\t"
for kmer in kmer_dictionary:
    count = kmer_dictionary
    out = (kmer, str(count))
    print(t.join(out))
    kmer1 = "t.join(out)"
    aip_kmers.write(t.join(out) + "\n")
    print(kmer1)

请问大神,代码一会得到非常多的数据, 请问如何把代码一大量的data代入到代码二开头的seq=“ ”里面

qq1151985918 发表于 2021-2-15 16:49:13

seq = data
页: [1]
查看完整版本: python 问题麻烦最帅的大神求助