Python
本帖最后由 leoric666 于 2021-2-15 09:45 编辑代码1
seq = 'GCCGGCCCTCAGACAGGAGTGGTCCTGGATGTGGATG'
kmer_length = 6
kmer_dictionary = {}
stop = len(seq) - kmer_length + 1
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))
代码2
aip_kmers = open("newlines.txt",'w')
kmer1 = "ATGCNA"
kmer2 = "AAGCNC"
# Append newline when using write
aip_kmers.write(kmer1 + "\n")
aip_kmers.write(kmer2 + "\n")
# Appending newline not needed when using print
print(kmer1)
aip_kmers.close()
请问大家我如何把代码一中的基因序列全部保存到想代码2那样的文件中
页:
[1]