Skip to content

Commit

Permalink
some warning about numbers for technical/biological and fractions
Browse files Browse the repository at this point in the history
  • Loading branch information
ypriverol committed Jul 30, 2024
1 parent 8f03ae2 commit 59d365e
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions sdrf_pipelines/sdrf/sdrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def check_if_integer(x):
except ValueError:
return False


class SdrfDataFrame(pd.DataFrame):
@property
def _constructor(self):
Expand Down Expand Up @@ -237,7 +238,11 @@ def check_integer_columns(df, columns):
return non_integer_rows

# Specify the columns to check
columns_to_check = ["comment[technical replicate]", "characteristics[biological replicate]", "comment[fraction identifier]"]
columns_to_check = [
"comment[technical replicate]",
"characteristics[biological replicate]",
"comment[fraction identifier]",
]

## Remove columns that are not present in the dataframe
columns_to_check = [col for col in columns_to_check if col in self.columns]
Expand All @@ -246,7 +251,12 @@ def check_integer_columns(df, columns):
non_integer_rows = check_integer_columns(self, columns_to_check)

if len(non_integer_rows) > 0:
errors.append(LogicError(f"Non-integer values found in the following columns and rows: {non_integer_rows}", error_type=logging.WARNING))
errors.append(
LogicError(
f"Non-integer values found in the following columns and rows: {non_integer_rows}",
error_type=logging.WARNING,
)
)

def check_all_integers_higher_than_one(df, columns):
"""
Expand All @@ -265,6 +275,11 @@ def check_all_integers_higher_than_one(df, columns):

lower_than_one = check_all_integers_higher_than_one(self, columns_to_check)
if len(lower_than_one) > 0:
errors.append(LogicError(f"Values lower than 1 found in the following columns and rows: {lower_than_one}", error_type=logging.WARNING))
errors.append(
LogicError(
f"Values lower than 1 found in the following columns and rows: {lower_than_one}",
error_type=logging.WARNING,
)
)

return errors
return errors

0 comments on commit 59d365e

Please sign in to comment.