Skip to content

Commit

Permalink
fix: removed backslash (#124)
Browse files Browse the repository at this point in the history
Need to match an actual S char not \S.

Thanks Copilot
  • Loading branch information
alsmith151 authored Feb 1, 2024
1 parent 27039e3 commit 3cebc80
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions seqnado/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,16 @@ def sample_name(self) -> str:
@property
def sample_base(self) -> str:
to_sub = {
r"_\S\d+_": "_",
r"_S\d+_": "_",
r"_L00\d_": "_",
r"_R?[12](_001)?$": "",
r"_R?[12](_001)?$": "_",
r"__": "_",
r"_$": "",
}

base = self.sample_name
for pattern, rep in to_sub.items():
base = re.sub(pattern, rep, base)

return base

@computed_field
Expand Down Expand Up @@ -230,13 +231,6 @@ def predict_ip(self) -> Optional[str]:
logger.warning(f"Could not predict IP for {self.sample_base}")
return None

def sample_name_without_antibody(self) -> str:
"""
Return the sample name without the antibody name.
"""
return re.sub(f"_{self.antibody}_", "_", self.sample_name)

def predict_is_control(self) -> bool:
"""
Return True if the fastq file is an input.
Expand All @@ -253,12 +247,15 @@ def sample_base_without_ip(self) -> str:
Return the sample base without the antibody name.
"""
return re.sub(
f"(_{self.ip})?(_S\\d+)?(_L00\\d)?(_R?[12])?(_001)?",
pattern = f"(_{self.ip})?(_S\\d+)?(_L00\\d)?(_R?[12])?(_001)?"
base = re.sub(
pattern,
"",
self.sample_name,
)

return base


class AssayNonIP(BaseModel):
name: str = Field(default=None, description="Name of the assay")
Expand Down Expand Up @@ -627,7 +624,6 @@ def to_dataframe(self, simplify: bool = True):

@classmethod
def from_dataframe(cls, df: pd.DataFrame, simplified: bool = True, **kwargs):

experiments = {}
for experiment_name, row in df.iterrows():
if simplified:
Expand Down

0 comments on commit 3cebc80

Please sign in to comment.