Commit b9a2bdbf authored by Akdel's avatar Akdel

simple repeat detect

parent 8f692b71
......@@ -4,6 +4,7 @@ from OptiMap.align import normalized_correlation as cr
import multiprocessing as mp
from scipy import ndimage
class CorrelationStruct:
def __init__(self, molecule_1: ms.Molecule, molecule_2: ms.Molecule, minimum_nick_number=9, bylength=False, return_new_signals=True):
self.long_id = True
......@@ -42,6 +43,8 @@ class CorrelationStruct:
self.new_short_length = None
self.new_long_length = None
self.delete_signals = (not return_new_signals)
# self.new_long_orig = None
# self.new_short_orig = None
# def re_correlate_with_original(self):
......@@ -63,6 +66,8 @@ class CorrelationStruct:
if log:
long_signal = self.long_molecule.log_signal
short_signal = self.short_molecule.log_signal
# orig_long = self.long_molecule.nick_signal + EPSILON
# orig_short = self.short_molecule.nick_signal + EPSILON
else:
long_signal = self.long_molecule.nick_signal + EPSILON
short_signal = self.short_molecule.nick_signal + EPSILON
......@@ -71,7 +76,7 @@ class CorrelationStruct:
short_signal,
step=0.001):
if zoomed_signal.shape[0] > long_signal.shape[0]:
short_change = True
short_change = True
_long = zoomed_signal
short = long_signal
else:
......
from OptiMap import *
from OptiScan import database as db
from scipy import ndimage
"""
The class here is intended to store single OM molecule attributes.
"""
......@@ -107,3 +108,16 @@ def create_molecule_stream_from_db(database_name: str, snr: float):
conn = database.MoleculeConnector(database_name)
molecule_stream = conn.yield_molecule_signals_in_all_runs()
return yield_molecules_from_stream(molecule_stream, snr)
def is_repeat(_mol):
result = ndimage.gaussian_filter1d(np.correlate(_mol, _mol[::-1], mode='same'), sigma=1.5)
mol_ = MoleculeNoBack(result, snr=1.5)
if len(mol_.nick_coordinates) < 6:
return False
nicks = np.array(mol_.nick_coordinates[0:6])
diffs = np.abs(nicks[:5]-nicks[1:6])
if (np.max(diffs) - np.min(diffs)) <= 2 and np.mean(diffs) >= 10:
return True
else:
return False
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment