Skip to content

Commit

Permalink
Update to v2.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjackson-pellicle committed Oct 30, 2024
1 parent cf183bf commit 31a9235
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions hybpiper/retrieve_sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,19 +578,26 @@ def recover_sequences_from_one_sample(seq_dir,
####################################################################################################################
# Write seqrecords to fasta file:
####################################################################################################################
for locus_name, seqrecord_list in loci_to_write_dict.items():
sequences_to_write = []

# Construct names for intron and supercontig output files:
if seq_dir in ['intron', 'supercontig']:
outfilename = f'{single_sample_name}_{locus_name}.fasta'
else:
outfilename = f'{single_sample_name}_{locus_name}_{seq_dir}.fasta'
# Construct names for intron and supercontig output files:
if seq_dir in ['intron', 'supercontig']:
outfilename = f'{single_sample_name}_{filename}.fasta'
else:
outfilename = f'{single_sample_name}_{seq_dir}.fasta'

with open(os.path.join(fasta_dir, outfilename), 'w') as fasta_handle:
SeqIO.write(seqrecord_list, fasta_handle, 'fasta')
for locus_name, seqrecord_list in loci_to_write_dict.items():

for seqrecord in seqrecord_list:
seqrecord.name = f'{seqrecord.name}-{locus_name}'
seqrecord.id = f'{seqrecord.id}-{locus_name}'
sequences_to_write.append(seqrecord)

logger.info(f'{"[INFO]:":10} Found {len(seqrecord_list)} sequences for gene {locus_name}')

with open(os.path.join(fasta_dir, outfilename), 'w') as fasta_handle:
SeqIO.write(sequences_to_write, fasta_handle, 'fasta')

logger.info(f'{"[INFO]:":10} Done!')


Expand Down

0 comments on commit 31a9235

Please sign in to comment.