擅长:python、mysql、java
<pre><code>sequence = open("out.list.txt").read() # reads in the file as a string
alignment_rows = open("out.test.txt").readlines() # reads in the file as a list of lines
# split each row by tab sign "\t" and extract sequences only - third column
# I assume, you're using tab sign as a separator in your alignment
alignment_sequences = [ row.split("\t")[2] for row in alignment_rows ]
output = {} # this is a dict, where keys are indices of positions with * and values are lists e.g. {1: ['A', 'C'], 2: ['D', 'E']}
for index, char in enumerate(sequence):
if char == "*":
output[index] = []
for alignment_sequence in alignment sequences:
output[index].append(alignment_sequence[index])
</code></pre>