File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,8 @@ def load_record(
9292
9393 return record
9494
95- def _load_records_from_zip_file (zip_file ):
95+
96+ def _load_records_from_zip_file (zip_file , use_file_names_as_ids = False ):
9697 """Return all fasta/genbank/snapgene in a zip as biopython records.
9798
9899 Each record gets a ``source_file`` attribute from the zip's file name
@@ -137,6 +138,10 @@ def _load_records_from_zip_file(zip_file):
137138 record .id = name
138139 record .id = name
139140 record .file_name = f ._name_no_extension
141+ if use_file_names_as_ids and single_record :
142+ basename = os .path .basename (record .source_file )
143+ basename_no_extension = os .path .splitext (basename )[0 ]
144+ record .id = basename_no_extension
140145 for record in new_records :
141146 record .source_file = f ._path
142147 records += new_records
@@ -193,7 +198,9 @@ def load_records_from_files(
193198 for filepath in files :
194199 filename = os .path .basename (filepath )
195200 if filename .lower ().endswith ("zip" ):
196- records += _load_records_from_zip_file (filepath )
201+ records += _load_records_from_zip_file (
202+ filepath , use_file_names_as_ids = use_file_names_as_ids
203+ )
197204 continue
198205 recs , fmt = load_records_from_file (filepath )
199206 single_record = len (recs ) == 1
Original file line number Diff line number Diff line change 1- __version__ = "2.0.0 "
1+ __version__ = "2.0.1 "
You can’t perform that action at this time.
0 commit comments