Skip to content

Commit 54fb18c

Browse files
authored
Create protein_converter.py
1 parent 92a7a8f commit 54fb18c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import sys
2+
from Bio import SeqIO
3+
4+
# Get input and output file paths from command-line arguments
5+
# Daniel Paiva Agustinho
6+
input_file = sys.argv[1]
7+
output_file = sys.argv[2]
8+
9+
with open(input_file, "r") as input_handle:
10+
with open(output_file, "w") as output_handle:
11+
for record in SeqIO.parse(input_handle, "fasta"):
12+
protein_seq = record.seq.translate()
13+
14+
# Extract the entire original header
15+
original_header = record.description
16+
17+
# Create a new sequence record with the original header
18+
protein_seq = SeqIO.SeqRecord(
19+
protein_seq, id=record.id, description=original_header
20+
)
21+
SeqIO.write(protein_seq, output_handle, "fasta")
22+
print("done",str(output_file))

0 commit comments

Comments
 (0)