Skip to content

Commit

Permalink
format strain_collection.py
Browse files Browse the repository at this point in the history
  • Loading branch information
CunliangGeng committed Oct 30, 2023
1 parent 4d230e9 commit 0815f48
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/nplinker/strain_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def add(self, strain: Strain) -> None:
if strain in self._strains:
# only one strain object per id
strain_ref = self._strain_dict_name[strain.id][0]
new_aliases = [alias for alias in strain.aliases if alias not in strain_ref.aliases]
new_aliases = [
alias for alias in strain.aliases
if alias not in strain_ref.aliases
]
for alias in new_aliases:
strain_ref.add_alias(alias)
if alias not in self._strain_dict_name:
Expand Down Expand Up @@ -92,14 +95,16 @@ def remove(self, strain: Strain):
for name in strain_ref.names:
if name in self._strain_dict_name:
new_strain_list = [
s for s in self._strain_dict_name[name] if s.id != strain.id
s for s in self._strain_dict_name[name]
if s.id != strain.id
]
if not new_strain_list:
del self._strain_dict_name[name]
else:
self._strain_dict_name[name] = new_strain_list
else:
raise ValueError(f"Strain {strain} not found in strain collection.")
raise ValueError(
f"Strain {strain} not found in strain collection.")

def filter(self, strain_set: set[Strain]):
"""
Expand Down

0 comments on commit 0815f48

Please sign in to comment.