Skip to content

Commit

Permalink
black run
Browse files Browse the repository at this point in the history
  • Loading branch information
ypriverol committed Oct 7, 2024
1 parent 4a5e3b5 commit ef4baee
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions sdrf_pipelines/ols/ols.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,17 @@ def build_ontology_index(ontology_file: str, output_file: str = None, ontology_n
df = pd.DataFrame(terms)

# Convert to lowercase as needed
df['accession'] = df['accession'].str.lower()
df['label'] = df['label'].str.lower()
df['ontology'] = df['ontology'].str.lower()
df["accession"] = df["accession"].str.lower()
df["label"] = df["label"].str.lower()
df["ontology"] = df["ontology"].str.lower()

# Enforce data types (schema)
df['accession'] = df['accession'].astype('string') # Ensuring a string type
df['label'] = df['label'].astype('string') # Ensuring a string type
df['ontology'] = df['ontology'].astype('string') # Ensuring a string type
df["accession"] = df["accession"].astype("string") # Ensuring a string type
df["label"] = df["label"].astype("string") # Ensuring a string type
df["ontology"] = df["ontology"].astype("string") # Ensuring a string type

# Remove terms with no label or accession and print a warning
df = df.dropna(subset=['label', 'accession'])
df = df.dropna(subset=["label", "accession"])
if df.empty:
logger.warning("No terms found in %s", ontology_file)
raise ValueError(f"No terms found in {ontology_file}")
Expand Down Expand Up @@ -436,7 +436,7 @@ def cache_search(self, term: str, ontology: str, full_search: bool = False) -> l
FROM read_parquet(?)
WHERE lower(CAST(label AS VARCHAR)) = lower(?)
AND lower(CAST(ontology AS VARCHAR)) = lower(?)""",
(self.parquet_files, term, ontology)
(self.parquet_files, term, ontology),
)
else:
# Query for case-insensitive search without ontology
Expand All @@ -446,7 +446,7 @@ def cache_search(self, term: str, ontology: str, full_search: bool = False) -> l
CAST(ontology AS VARCHAR) AS ontology
FROM read_parquet(?)
WHERE lower(CAST(label AS VARCHAR)) = lower(?)""",
(self.parquet_files, term)
(self.parquet_files, term),
)
df = duckdb_conn.fetchdf()

Expand Down

0 comments on commit ef4baee

Please sign in to comment.