From 01a1d61664236e0ea0f51f8ab343eae7d45d55b7 Mon Sep 17 00:00:00 2001 From: Remi Planel <rplanel@pasteur.fr> Date: Thu, 30 Jan 2020 21:05:37 +0100 Subject: [PATCH] Bug not feature in off-target --- crisprbact/predict.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/crisprbact/predict.py b/crisprbact/predict.py index 265a7f0..14a3eac 100644 --- a/crisprbact/predict.py +++ b/crisprbact/predict.py @@ -73,25 +73,28 @@ def on_target_predict(seq, genome=None, seed_size=7): ) off_targets_list = [] off_targets = off_target_df.loc[ - 0:, ["start", "end", "pampos", "features"] + 0:, ["start", "end", "pampos", "strand", "features"] ] for index, off_t in enumerate(off_targets.values.tolist()): - off_target_dict = { "off_target_start": off_t[0], "off_target_end": off_t[1], "pampos": off_t[2], + "strand": off_t[3], } - for feat in off_t[3]: - feature_dict = { - "feat_strand": feat.location.strand, - "feat_start": feat.location.start, - "feat_end": feat.location.end, - "feat_type": feat.type, - } - for k, feat in feat.qualifiers.items(): - if k != "translation": - feature_dict[k] = " :: ".join(feat) + if len(off_t[4]) > 0: + for feat in off_t[4]: + feature_dict = { + "feat_strand": feat.location.strand, + "feat_start": feat.location.start, + "feat_end": feat.location.end, + "feat_type": feat.type, + } + for k, feat in feat.qualifiers.items(): + if k != "translation": + feature_dict[k] = " :: ".join(feat) + off_targets_list.append(off_target_dict) + else: off_targets_list.append({**feature_dict, **off_target_dict}) target.update({"off_targets": off_targets_list}) else: -- GitLab