Skip to content

Commit

Permalink
feat: add --thiol3 arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Paradoxdruid committed May 10, 2023
1 parent a2e8e8f commit 6c3c780
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
23 changes: 19 additions & 4 deletions fealden/fealden.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ def main() -> None:
parser.add_argument(
"--fixed",
action="store_true",
help="Fix methylene blue to 3' termini, no file output",
help="Fix methylene blue to 3' termini",
)
parser.add_argument(
"--thiol3",
action="store_false",
help="Fix thiol to 3' termini",
)
parser.add_argument(
"-out",
Expand Down Expand Up @@ -161,11 +166,17 @@ def main() -> None:
args.interactive,
args.out,
args.fixed,
args.thiol3,
)


def generate_sensor(
seed: seed.Seed, rec_seq: str, num_poss_sen: int, core: int, fixed: bool
seed: seed.Seed,
rec_seq: str,
num_poss_sen: int,
core: int,
fixed: bool,
thiol: bool,
) -> list[sensor.Sensor]:
"""
generate_sensor() gens a # of possible sensors and returns a list of valid sensors.
Expand All @@ -190,7 +201,7 @@ def generate_sensor(

while version < num_poss_sen:
version += 1
sen = seed.build_sensor(core, version, rec_seq, fixed)
sen = seed.build_sensor(core, version, rec_seq, fixed, thiol)

# only keep good sensors
if sen is None:
Expand Down Expand Up @@ -239,6 +250,7 @@ def __init__(
interactive: bool,
output_file: str,
fixed: bool,
thiol: bool,
) -> None:
"""Initialize new Fealden instance."""
self.rec_seq = rec_seq
Expand Down Expand Up @@ -270,7 +282,10 @@ def __init__(
while i < num_process:
i += 1
tasks.extend(
[(s, self.rec_seq, seed_sens_per_process, i, fixed) for s in seeds]
[
(s, self.rec_seq, seed_sens_per_process, i, fixed, thiol)
for s in seeds
]
)

for t in tasks:
Expand Down
5 changes: 1 addition & 4 deletions fealden/fold.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ def get_distance(self, index1: int, index2: int) -> int:
distance <- an integer, the calculated distance
"""
if index1 > index2:
# TODO: Double-check this implementation
# temp = index1
index1 = index2
index2 = index1
index1, index2 = index2, index1

node1 = self.ptr_list[index1 - 1]
node2 = self.ptr_list[index2 - 1]
Expand Down
8 changes: 7 additions & 1 deletion fealden/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,12 @@ def build_the_rest(
self.build_the_rest(data[1:], nodes)

def build_sensor(
self, core: int, version: int, base_seq: str, fixed: bool
self,
core: int,
version: int,
base_seq: str,
fixed: bool,
thiol: bool,
) -> sensor.Sensor | None:
"""
build_sensor() first builds a 'Sensor' sequence using the 'Seed' of 'self'
Expand Down Expand Up @@ -225,6 +230,7 @@ def build_sensor(
self.name,
base_seq,
fixed,
thiol,
)

def generate_node_sizes(self) -> None:
Expand Down
8 changes: 6 additions & 2 deletions fealden/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(
seed_name: str,
base_seq: str,
fixed: bool,
thiol: bool = True,
):
"""
This is the constructor for Sensor.
Expand Down Expand Up @@ -58,6 +59,7 @@ def __init__(
self.on_to_off_dist = 0
self.base_seq = base_seq
self.fixed = fixed
self.thiol = thiol
(self.tag_loc, self.score) = self.get_tag_and_score()

def interpret_data(
Expand Down Expand Up @@ -235,8 +237,10 @@ def get_tag_locations(
# various folds

# Fixed Methylene blue at 3' terminus
thiol_loc = len(self.seq) if not self.thiol else 1

if self.fixed is True:
distances = [f.get_distance(1, len(self.seq)) for f in self.folds]
distances = [f.get_distance(thiol_loc, len(self.seq)) for f in self.folds]
tag_locs.append((len(self.seq), distances))

# Else discover internal T placements
Expand All @@ -247,7 +251,7 @@ def get_tag_locations(
and (i + 1 < self.rec_seq["start"] or i + 1 > self.rec_seq["end"])
and (i + 1 < self.resp_seq["start"] or i + 1 > self.resp_seq["end"])
):
distances = [f.get_distance(1, i + 1) for f in self.folds]
distances = [f.get_distance(thiol_loc, i + 1) for f in self.folds]
smallest_dist = min(distances)
if (
smallest_dist <= MAX_ON_DIST
Expand Down

0 comments on commit 6c3c780

Please sign in to comment.