I'm attempting to create a list comprehension from a nested for loop with if statements, and I can't figure it out. I scanned the internet for hours but couldn't find a solution.
The loop looks like that:
identical_ids = None
with open(fasta_path_, 'r') as fasta_file:
for line in fasta_file.readlines():
if identical_ids is True:
lengths.append(len(line.strip()))
for seq_id in seqids:
if seq_id in line:
identical_ids = True
continue
else:
identical_ids = False
continue
My last attempt:
lengths = [len(line.strip()) for line in fasta_file.readlines() if identical_ids for seq_id in seqids if seq_id in line identical_ids := True else identical_ids := False]
Maybe it can't be done.
Thanks.
Aucun commentaire:
Enregistrer un commentaire