-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprint_sites_with_positions.py
More file actions
31 lines (25 loc) · 1010 Bytes
/
Copy pathprint_sites_with_positions.py
File metadata and controls
31 lines (25 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def print_sites_with_positions(sites_list):
"""
Print a list of sites with their positions horizontally and vertically aligned.
Input: a list of tuples, each containing an amino acid/nucleotide and a position.
Output: None, but prints the amino acids horizontally and the positions vertically aligned.
"""
amino_acids = [site[0] for site in sites_list]
positions = [str(site[1]) for site in sites_list]
# Print amino acids horizontally
print("".join(amino_acids))
# Find the maximum number of digits in positions
max_digits = max(len(pos) for pos in positions)
# Print positions vertically aligned
for i in range(max_digits):
for pos in positions:
if len(pos) > i:
print(pos[i], end="")
else:
print(" ", end="")
print()
if __name__ == "__main__":
# Example usage:
import random
x = [(random.choice("ATGC"), i + 1) for i in range(60)]
print_sites_with_positions(x)