Skip to content

Commit

Permalink
FIX handle edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgWa committed Oct 16, 2023
1 parent 148a841 commit a1ba433
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions alphabase/protein/fasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,11 @@ def annotate_precursor_df(
updated precursor_df with `genes`, `proteins` and `cardinality` columns.
"""
if len(precursor_df) == 0:
return precursor_df

if len(protein_df) == 0:
return precursor_df

if 'sequence' not in precursor_df.columns:
raise SystemError('precursor_df must contain a sequence column')
Expand Down Expand Up @@ -1379,6 +1384,9 @@ def annotate_precursor_df(
if 'proteotypic' in precursor_df.columns:
precursor_df.drop(columns=['proteotypic'], inplace=True)

if 'cardinality' in precursor_df.columns:
precursor_df.drop(columns=['cardinality'], inplace=True)

failed_annotation = np.sum(peptide_df['genes'] == '')
if failed_annotation > 0:
warnings.warn(f'{failed_annotation} peptides could not be annotated')
Expand Down

0 comments on commit a1ba433

Please sign in to comment.