Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions openfold/utils/script_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,23 @@ def load_models_from_command_line(config, model_device, openfold_checkpoint_path


def parse_fasta(data):
# Remove any empty lines or trailing ">" characters
data = re.sub('>$', '', data, flags=re.M)
lines = [
l.replace('\n', '')
for prot in data.split('>') for l in prot.strip().split('\n', 1)
][1:]
tags, seqs = lines[::2], lines[1::2]

tags = [re.split('\W| \|', t)[0] for t in tags]


# Split the data into entries based on '>'
entries = data.split('>')[1:] # Skip the first empty element

tags = []
seqs = []

for entry in entries:
lines = entry.split('\n', 1)
if len(lines) == 2:
tag = lines[0].strip() # Take the full tag (header)
seq = lines[1].replace('\n', '').strip() # Remove newlines and any extra spaces in the sequence
tags.append(tag)
seqs.append(seq)

return tags, seqs


Expand Down