Skip to content

Commit

Permalink
Fix pfam_id column missing on empty dataframes
Browse files Browse the repository at this point in the history
  • Loading branch information
prihoda committed Apr 1, 2022
1 parent e3952d7 commit 3b6edb0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions deepbgc/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ def __init__(self, column='pfam_id', sequence_as_vector=True):
self.sequence_as_vector = sequence_as_vector

def transform(self, X):
if X.empty:
X = pd.DataFrame({self.column: []})
if self.column not in X.columns:
raise ValueError('Unexpected pfam dataframe, column "{}" not found in: {}'.format(self.column, X.columns))
# Turn each pfam ID into a vector
values = pd.get_dummies(X[self.column]).reindex(columns=self.unique_values, fill_value=0)
if self.sequence_as_vector:
Expand Down

0 comments on commit 3b6edb0

Please sign in to comment.