Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
use setdefault to init dict keys
  • Loading branch information
oschwengers committed Aug 11, 2023
1 parent eb4dc89 commit 37546f1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions bakta/expert/amrfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ def search(cdss: Sequence[dict], cds_fasta_path: Path):
hit['id'] = hmm_id
hit['db_xrefs'] = [f'{bc.DB_XREF_NCBI_FAMILIES}:{hmm_id}']

if('expert' not in cds):
cds['expert'] = []
cds.setdefault('expert', [])
cds['expert'].append(hit)
log.debug(
'hit: gene=%s, product=%s, method=%s, target-cov=%0.3f, identity=%0.3f, contig=%s, start=%i, stop=%i, strand=%s',
Expand Down
3 changes: 1 addition & 2 deletions bakta/expert/protein_sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ def search(cdss: Sequence[dict], cds_fasta_path: Path, expert_system: str, db_pa
}
if(expert_system == 'user_proteins'):
hit['db_xrefs'].append(f'UserProtein:{model_id}')
if('expert' not in cds):
cds['expert'] = []
cds.setdefault('expert', [])
cds['expert'].append(hit)
log.debug(
'hit: source=%s, rank=%i, contig=%s, start=%i, stop=%i, strand=%s, query-cov=%0.3f, model-cov=%0.3f, identity=%0.3f, gene=%s, product=%s, evalue=%1.1e, bitscore=%f',
Expand Down

0 comments on commit 37546f1

Please sign in to comment.