@@ -33,6 +33,8 @@ def run(assembly_fp, output_fp):
3333 elif assembly_filetype == 'fasta' :
3434 assembly_genbank_fp = None
3535 assembly_fasta_fp = assembly_fp
36+ else :
37+ assert False
3638 print ('========================================' )
3739 prodigal_data = run_prodigal (assembly_fasta_fp )
3840 prodigal_orfs = parse_prodigal_output (prodigal_data )
@@ -114,6 +116,7 @@ def get_qual_note(partial_str):
114116
115117
116118def match_existing_orfs_updated_annotations (new_fp , existing_fp , overlap_min = 0.80 ):
119+ # pylint: disable=too-many-branches
117120 # Get features and create list of start and end objects for each
118121 features_new = collect_all_features (new_fp )
119122 features_existing = collect_all_features (existing_fp )
@@ -126,17 +129,17 @@ def match_existing_orfs_updated_annotations(new_fp, existing_fp, overlap_min=0.8
126129 # Find overlaps
127130 positions = contig_positions_new [contig ] + contig_positions_existing [contig ]
128131 features_matched = discover_overlaps (positions , overlap_min )
129-
132+
130133 # Discover those not matched using location comparison
131134 features_matched_new = [f [0 ] for f in features_matched ]
132135 features_matched_existing = [f [1 ] for f in features_matched ]
133-
136+
134137 # Find unmatched features by comparing locations
135138 new_unmatched = []
136139 for feature in features_new [contig ]:
137140 if not any (f .location == feature .location for f in features_matched_new ):
138141 new_unmatched .append (feature )
139-
142+
140143 existing_unmatched = []
141144 for feature in features_existing [contig ]:
142145 if not any (f .location == feature .location for f in features_matched_existing ):
@@ -151,7 +154,7 @@ def match_existing_orfs_updated_annotations(new_fp, existing_fp, overlap_min=0.8
151154 continue
152155 feature_new .qualifiers [qual ] = feature_existing .qualifiers [qual ]
153156 features_updated .append (feature_new )
154-
157+
155158 # Add existing ORFs that had no match
156159 features_updated .extend (new_unmatched )
157160 features_updated .extend (existing_unmatched )
@@ -163,7 +166,7 @@ def match_existing_orfs_updated_annotations(new_fp, existing_fp, overlap_min=0.8
163166 print (f'\t { len (existing_unmatched )} existing features unmatched' )
164167 print (f'\t { len (new_unmatched )} re-annotated features unmatched' )
165168 print (f'\t { len (features_updated )} total features' )
166-
169+
167170 # Update new genbank with new feature set
168171 update_genbank_annotations (new_fp , contig_features_updated )
169172
@@ -214,7 +217,7 @@ def discover_overlaps(positions, overlap_min):
214217 continue
215218 # Check if this pair is already matched by comparing locations
216219 already_matched = any (
217- fn .location == feature_new .location and fe .location == feature_existing .location
220+ fn .location == feature_new .location and fe .location == feature_existing .location
218221 for fn , fe in features_matched
219222 )
220223 if already_matched :
0 commit comments