From c9f5cced51a8c3970b36003f32ec39e846af01d5 Mon Sep 17 00:00:00 2001
From: Remi Planel <rplanel@pasteur.fr>
Date: Tue, 17 Mar 2020 17:05:41 +0100
Subject: [PATCH] Add to the result the biggest match between the guide and the
 off-target

---
 crisprbact/predict.py | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/crisprbact/predict.py b/crisprbact/predict.py
index bb5c397..5609a91 100644
--- a/crisprbact/predict.py
+++ b/crisprbact/predict.py
@@ -89,7 +89,16 @@ def on_target_predict(seq, genome=None, seed_sizes=[8, 9, 10, 11, 12]):
                     if off_target_df is not None and not off_target_df.empty:
                         off_targets = off_target_df.loc[
                             0:,
-                            ["start", "end", "pampos", "strand", "recid", "features"],
+                            [
+                                "start",
+                                "end",
+                                "pampos",
+                                "strand",
+                                "recid",
+                                "max_matching_len",
+                                "max_matching_seq",
+                                "features",
+                            ],
                         ]
                         for j, off_t in enumerate(off_targets.values.tolist()):
                             off_target_dict = {
@@ -103,12 +112,14 @@ def on_target_predict(seq, genome=None, seed_sizes=[8, 9, 10, 11, 12]):
                                 "off_target_pampos": off_t[2],
                                 "off_target_strand": off_t[3],
                                 "off_target_recid": off_t[4],
+                                "off_target_max_matching_seq": off_t[6],
                                 "off_target_good_orientation": None,
                             }
+                            index_features = 7
                             # Loop through features associated to an off-target position
-                            if len(off_t[5]) > 0:
+                            if len(off_t[index_features]) > 0:
                                 # Loop for each feature
-                                for feat in off_t[5]:
+                                for feat in off_t[index_features]:
                                     if get_strand_value(
                                         off_target_dict["off_target_strand"]
                                     ) != get_strand_value(feat.location.strand):
-- 
GitLab