Skip to content
Snippets Groups Projects
Commit b9ee273f authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

Fix bug no off-target feature. Fix #6

parent aeac9e45
No related branches found
No related tags found
No related merge requests found
Pipeline #23472 passed
# 0.3.2
- Fix bugg when no off-target feature
- Handle genome in fasta file
# 0.3.1 # 0.3.1
- Fix bug when no feature - Fix bug when no feature
- Add off-target strand to output - Add off-target strand to output
......
...@@ -72,31 +72,38 @@ def on_target_predict(seq, genome=None, seed_size=7): ...@@ -72,31 +72,38 @@ def on_target_predict(seq, genome=None, seed_size=7):
target["guide"], seed_size, records, genome_features target["guide"], seed_size, records, genome_features
) )
off_targets_list = [] off_targets_list = []
off_targets = off_target_df.loc[ if not off_target_df.empty:
0:, ["start", "end", "pampos", "strand", "features"] off_targets = off_target_df.loc[
] 0:, ["start", "end", "pampos", "strand", "recid", "features"]
for index, off_t in enumerate(off_targets.values.tolist()): ]
off_target_dict = { for index, off_t in enumerate(off_targets.values.tolist()):
"off_target_start": off_t[0], off_target_dict = {
"off_target_end": off_t[1], "off_target_start": off_t[0],
"pampos": off_t[2], "off_target_end": off_t[1],
"strand": off_t[3], "pampos": off_t[2],
} "strand": off_t[3],
if len(off_t[4]) > 0: "recid": off_t[4],
for feat in off_t[4]: }
feature_dict = { if len(off_t[5]) > 0:
"feat_strand": feat.location.strand, # Loop for each feature
"feat_start": feat.location.start, for feat in off_t[5]:
"feat_end": feat.location.end, feature_dict = {
"feat_type": feat.type, "feat_strand": feat.location.strand,
} "feat_start": feat.location.start,
for k, feat in feat.qualifiers.items(): "feat_end": feat.location.end,
if k != "translation": "feat_type": feat.type,
feature_dict[k] = " :: ".join(feat) }
for k, feat in feat.qualifiers.items():
if k != "translation":
feature_dict[k] = "::".join(feat)
off_targets_list.append(
{**feature_dict, **off_target_dict}
)
else:
off_targets_list.append(off_target_dict) off_targets_list.append(off_target_dict)
else: target.update({"off_targets": off_targets_list})
off_targets_list.append({**feature_dict, **off_target_dict}) else:
target.update({"off_targets": off_targets_list}) target.update({"off_targets": off_targets_list})
else: else:
target.update({"off_targets": []}) target.update({"off_targets": []})
return alltargets return alltargets
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment