Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jfnavarro committed Jan 8, 2025
1 parent dd71969 commit 227b119
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions scripts/adjust_matrix_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def main(counts_matrix: str, coordinates_file: str, update_coordinates: bool, ou
return 1

if not outfile:
outfile = "adjusted_{}".format(os.path.basename(counts_matrix))
outfile = f"adjusted_{os.path.basename(counts_matrix)}"

# Get a map of the new coordinates
new_coordinates = dict()
Expand Down Expand Up @@ -70,7 +70,7 @@ def main(counts_matrix: str, coordinates_file: str, update_coordinates: bool, ou
new_x, new_y = new_coordinates[(x, y)]
if not update_coordinates:
new_x, new_y = x, y
new_index_values.append("{0}x{1}".format(new_x, new_y))
new_index_values.append(f"{new_x}x{new_y}")
except KeyError:
counts_table.drop(index, inplace=True)

Expand Down
12 changes: 5 additions & 7 deletions scripts/convertEnsemblToNames.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def main(st_data_file: str, annotation: str, output_file: str) -> int:
try:
gene_map[line["gene_id"]] = line["gene_name"]
except KeyError as e:
print("Error, parsing annotation file, missing key {}".format(e))
print(f"Error, parsing annotation file, missing key {e}")
return 1
assert (len(gene_map) > 0)

Expand All @@ -38,14 +38,14 @@ def main(st_data_file: str, annotation: str, output_file: str) -> int:

# Check that the annotation file given was valid
if len(gene_map) < len(st_data.columns):
print("Error, the annotation file given is invalid or does not match the ST data")
print(f"Error, the annotation file given is invalid or does not match the ST data")
return 1

# Checks that there are no duplicated genes ids in the input data
gene_ids_counter = Counter(st_data.columns)
for gene_id, count in gene_ids_counter.most_common():
if count > 1:
print("Error, Ensembl ID {} was found {} times in the input matrix.".format(gene_id, count))
print(f"Error, Ensembl ID {gene_id} was found {count} times in the input matrix.")
return 1

# Iterates the genes IDs to get gene names
Expand All @@ -62,11 +62,9 @@ def main(st_data_file: str, annotation: str, output_file: str) -> int:
# so we keep the Ensembl ID.
# We assume input Ensembl ids are unique as we checked this before
gene_name = gene_id
print("Warning, gene name {} was already matched so the original "
"Ensembl ID {} will be kept".format(gene_name, gene_id))
print(f"Warning, gene name {gene_name} was already matched so the original Ensembl ID {gene_id} will be kept")
except KeyError:
print("Warning, {} was not found in the annotation, "
"so the original Ensembl ID will be kept".format(gene_id))
print(f"Warning, {gene_id} was not found in the annotation so the original Ensembl ID will be kept")
gene_name = gene_id
adjustedList.append(gene_name)

Expand Down
2 changes: 1 addition & 1 deletion scripts/filter_gene_type_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def main(counts_matrix: str, gene_types_keep: List[str], outfile: str, annotatio
if gene_types[gene] not in gene_types_keep:
genes_drop.append(gene)
except KeyError:
print("Warning, {} was not found in the annotation\n".format(gene))
print(f"Warning, {gene} was not found in the annotation")

if len(genes_drop) > 0:
counts_table.drop(genes_drop, axis=1, inplace=True)
Expand Down

0 comments on commit 227b119

Please sign in to comment.