Skip to content

Commit

Permalink
Refactor target_pam_handler.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandward committed Mar 1, 2024
1 parent 7a040a6 commit 804de2e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion target_pam_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
from Bio.Seq import Seq


def extract_downstream_pam(
pam,
tar_start,
Expand Down Expand Up @@ -100,11 +101,13 @@ def extract_upstream_pam(

return extracted_pam


# Filter out spacers that don't match the PAM
def filter_offtargets_by_pam(df):
targeting_spacers = df[df["target"].notna()]["spacer"].unique()
return df[~((df["target"].isna()) & (df["spacer"].isin(targeting_spacers)))]


# Check if the extracted PAM matches the PAM pattern
def pam_matches(pam_pattern, extracted_pam):
# Convert N to . for regex matching
Expand All @@ -115,4 +118,4 @@ def pam_matches(pam_pattern, extracted_pam):
return True

regex_pattern = pam_pattern.replace("N", ".")
return bool(re.match(regex_pattern, extracted_pam))
return bool(re.match(regex_pattern, extracted_pam))

0 comments on commit 804de2e

Please sign in to comment.