Skip to content

Motif search slow due to inefficient logodds reformatting #2360

Closed

Description

@Phlya

Biopython's motif search is very slow for long sequences. For example, running it for a "random" 500 kbp sequence for the mouse genome with a CTCF motif takes ~2.5 minutes.

Here is a realistic example of a code to annotate motifs that I ran for a 500 kbp sequence:

%%prun
sites = []
bg = {'A':seq.count('A')/l, 'T':seq.count('T')/l, 'G':seq.count('G')/l, 'C':seq.count('C')/l}
pssm = pfm.pwm.log_odds(bg)
print('Got PSSM')
sl = len(pfm)
i = 0
t = time.time()
for pos, score in pssm.search(seq, threshold=7):
    if abs(pos) >= i:
        print(i, len(sites), time.time()-t)
        i += 10000
    if pos < 0:
        strand = '-'
        start = l+pos-sl          
    else:
        strand = '+'
        start = pos
    sites.append([chrom, start, start+sl, strand, score])
sites = pd.DataFrame.from_records(sites, columns=['Chromosome', 'Start', 'End', 'Strand', 'Score'])
Got PSSM
0 0 2.0478174686431885
10000 2 4.058326721191406
20000 3 4.646576166152954
30000 4 4.920068979263306
40000 5 5.375012636184692
50000 6 5.443111896514893
60000 8 6.0875067710876465
70000 13 11.027215480804443
80000 15 11.987048625946045
90000 19 17.511669397354126
100000 21 18.390772104263306
110000 25 19.8211829662323
120000 27 20.215988636016846
130000 28 20.231982707977295
140000 29 21.383938550949097
150000 31 22.255633115768433
160000 32 23.772958755493164
170000 33 23.932071447372437
180000 34 25.212602138519287
190000 35 25.851369857788086
200000 36 27.52578067779541
210000 40 29.91758108139038
220000 41 32.79414367675781
230000 42 33.60089659690857
240000 44 34.95528721809387
250000 46 35.159255504608154
260000 47 35.528780937194824
270000 48 36.44404315948486
280000 49 36.45104694366455
290000 50 37.153515577316284
300000 55 39.4925754070282
310000 58 40.15520477294922
320000 59 40.58962845802307
330000 60 40.729615926742554
340000 62 42.952834129333496
350000 65 44.504544734954834
360000 160 114.50919079780579
370000 167 118.49372220039368
380000 169 121.2152419090271
390000 175 124.65023851394653
400000 179 127.58756136894226
410000 185 131.23024106025696
420000 190 136.9982407093048
430000 191 137.73300671577454
440000 196 140.6570725440979
450000 204 151.1570451259613
460000 206 152.5533037185669
470000 207 154.19884824752808
480000 210 157.08620762825012
490000 211 157.83301162719727

Here are the top few lines of prun output:

637986800 function calls (637986785 primitive calls) in 152.975 seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
 75997576   69.802    0.000  110.334    0.000 matrix.py:93(__getitem__)
380988464   30.814    0.000   30.814    0.000 {built-in method builtins.isinstance}
 18999316   21.019    0.000  131.352    0.000 matrix.py:34(<listcomp>)
   999986    8.175    0.000    8.175    0.000 {built-in method numpy.array}
 75997576    5.105    0.000    5.105    0.000 {function GenericPositionMatrix.__getitem__ at 0x7f69edae3b70}
77997651/77997636    4.955    0.000    4.955    0.000 {built-in method builtins.len}
      216    4.300    0.020  159.012    0.736 matrix.py:408(search)
   999964    2.453    0.000  150.575    0.000 matrix.py:28(_calculate)
   999964    2.279    0.000  153.734    0.000 matrix.py:380(calculate)
   999970    1.228    0.000    1.228    0.000 {built-in method numpy.empty}
   999964    1.222    0.000    1.222    0.000 {built-in method Bio.motifs._pwm.calculate}

As one might notice, the first line in the profiler output is matrix.py:93(__getitem__), and it takes almost 2 minutes of cumtime. I think, this is coming from

logodds = numpy.array([[score_dict[letter][i] for letter in "ACGT"]
- basically, for every position in the sequence, every position of the matrix is extracted and reformatted into an array! This seems like a complete waste of time, when this array could be created once at object creation time, and then just used directly.

I am very inexperienced with OOP, so my attempts at creating a PR failed, however I assumer it would be trivial.

Another issue, and why I added timings and number of motifs found every 10 kbp, is that clearly when there is a lot of hits with the minimum score, for some reason it slows down the code a lot, e.g. look at the jump at 360000! I am not sure why this is happening though. And I have repeated the run with all additional code for adding found motifs to a list etc commented out, and it doesn't make a difference.

Activity

  1. peterjc commented on Nov 27, 2019

    @peterjc
    Member

    Do you have a complete example? You are missing import time and the definition of pfm

    Does replacing this:

            logodds = numpy.array([[score_dict[letter][i] for letter in "ACGT"]
                                   for i in range(m)], float)

    with:

            letter_scores = score_dict[letter]
            logodds = numpy.array(
                [[score_dict["A"][i], score_dict["C"][i], score_dict["G"][i], score_dict["T"][i]]
                 for i in range(m)],
                float
            )

    help a little? Probably only a tiny bit.

    Beyond that perhaps @mdehoon can comment. I wondered if maybe the C code could take a scores dictionary rather than an array... or if the GenericPositionMatrix class could have an .as_array() method?

  2. Phlya commented on Nov 27, 2019

    @Phlya
    ContributorAuthor

    Sorry, I can make a complete example, but would need to share a long fasta file and the pfm then - this was just meant as a demonstration.

    Your suggestion would still lead to the same number of getitem calls, I think? That seems to be main culprit.

    I would just do something like this somewhere at initialisation:
    self.array = numpy.vstack([self[nt] for nt in 'AGCT']).T
    And then use self.array - or .as_array() would work as well if it just returns the stored array.

    The problem is the code path for systems without numpy...

  3. Phlya commented on Nov 27, 2019

    @Phlya
    ContributorAuthor

    Here is a complete example:

    %%prun
    import time
    import pandas as pd
    from Bio import SeqIO
    from Bio import motifs
    from Bio.Alphabet import generic_dna
    
    with open('/home/s1529682/CTCF_human.txt') as handle:
        pfm = motifs.read(handle, "jaspar")
    
    with open('/home/s1529682/test_seq.txt') as f:
        seq = SeqIO.read(f, 'fasta')
        seq = seq.seq
    
    l = len(seq)
    sites = []
    bg = {'A':seq.count('A')/l, 'T':seq.count('T')/l, 'G':seq.count('G')/l, 'C':seq.count('C')/l}
    pssm = pfm.pwm.log_odds(bg)
    print('Got PSSM')
    sl = len(pfm)
    i = 0
    t = time.time()
    for pos, score in pssm.search(seq, threshold=7):
        if abs(pos) >= i:
            print(i, len(sites), time.time()-t)
            i += 10000
        if pos < 0:
            strand = '-'
            start = l+pos-sl          
        else:
            strand = '+'
            start = pos
        sites.append([start, start+sl, strand, score])
    sites = pd.DataFrame.from_records(sites, columns=['Start', 'End', 'Strand', 'Score'])

    test_seq.txt
    CTCF_human.txt

  4. peterjc commented on Nov 27, 2019

    @peterjc
    Member

    Can you clarify what platform you are on - CPython, PyPy, other; has the C code in your Biopython been compiled and installed; and if you have numpy installed or not.

    I suspect that with the current state of PyPy support for C code we can now remove the pure-python fall back as it is no longer needed (numpy would be required).

  5. Phlya commented on Nov 27, 2019

    @Phlya
    ContributorAuthor

    Sorry - it's CPython on Ubuntu 18.04, and I installed biopython from PyPI - so I guess I have the C code installed? Numpy is installed.

  6. peterjc commented on Nov 27, 2019

    @peterjc
    Member

    What does this do on your system?

    $ python -c "from Bio.motifs import _pwm; print(dir(_pwm))"
    

    I'm trying to confirm which of the two _calculate functions is being called, the first one (requires our C code and numpy), or the second slower pure python one:

    https://github.com/biopython/biopython/blob/biopython-175/Bio/motifs/matrix.py#L28
    https://github.com/biopython/biopython/blob/biopython-175/Bio/motifs/matrix.py#L46

    This might answer more directly:

    $ python -c "from Bio.motifs.matrix import _calculate; help(_calculate)"
    

    I get this screen - press Q to get out - showing the C code is available:

    Help on function _calculate in module Bio.motifs.matrix:
    
    _calculate(score_dict, sequence, m)
        Calculate scores using C code (PRIVATE).
    (END)
    
  7. Phlya commented on Nov 27, 2019

    @Phlya
    ContributorAuthor

    I'm getting the same screen as you with the second command.

  8. Phlya commented on Nov 27, 2019

    @Phlya
    ContributorAuthor

    I tried simply doing this to test performance improvement:

    diff --git a/Bio/motifs/matrix.py b/Bio/motifs/matrix.py
    index 7dd5de127..11c6bdc9d 100644
    --- a/Bio/motifs/matrix.py
    +++ b/Bio/motifs/matrix.py
    @@ -25,15 +25,15 @@ try:
         # the Python standard library instead of numpy arrays; this would still
         # allow us to use the C module.
     
    -    def _calculate(score_dict, sequence, m):
    +    def _calculate(score_array, sequence, m):
             """Calculate scores using C code (PRIVATE)."""
             n = len(sequence)
             # Create the numpy arrays here; the C module then does not rely on numpy
             # Use a float32 for the scores array to save space
             scores = numpy.empty(n - m + 1, numpy.float32)
    -        logodds = numpy.array([[score_dict[letter][i] for letter in "ACGT"]
    -                               for i in range(m)], float)
    -        _pwm.calculate(sequence, logodds, scores)
    +#        logodds = numpy.array([[score_dict[letter][i] for letter in "ACGT"]
    +#                               for i in range(m)], float)
    +        _pwm.calculate(sequence, score_array, scores)
             return scores
     
     except ImportError:
    @@ -77,6 +77,7 @@ class GenericPositionMatrix(dict):
                     raise Exception("data has inconsistent lengths")
                 self[letter] = list(values[letter])
             self.alphabet = alphabet
    +        self.array = numpy.vstack([self[letter] for letter in 'AGCT']).T
     
         def __str__(self):
             """Return a string containing nucleotides and counts of the alphabet in the Matrix."""
    @@ -398,7 +399,7 @@ class PositionSpecificScoringMatrix(GenericPositionMatrix):
             # case would impose an overhead to allocate the extra memory.
             sequence = str(sequence)
             m = self.length
    -        scores = _calculate(self, sequence, m)
    +        scores = _calculate(self.array, sequence, m)
     
             if len(scores) == 1:
                 return scores[0]

    But I get an error, that I don't understand:

    ---------------------------------------------------------------------------
    RuntimeError                              Traceback (most recent call last)
    <ipython-input-1-21b5005b3eff> in <module>
    ----> 1 get_ipython().run_cell_magic('prun', '', 'import time\nimport pandas as pd\nfrom Bio import SeqIO\nfrom Bio import motifs\nfrom Bio.Alphabet import generic_dna\n\nwith open(\'/home/s1529682/CTCF_human.txt\') as handle:\n    pfm = motifs.read(handle, "jaspar")\n\nwith open(\'/home/s1529682/test_seq.txt\') as f:\n    seq = SeqIO.read(f, \'fasta\')\n    seq = seq.seq\n\nl = len(seq)\nsites = []\nbg = {\'A\':seq.count(\'A\')/l, \'T\':seq.count(\'T\')/l, \'G\':seq.count(\'G\')/l, \'C\':seq.count(\'C\')/l}\npssm = pfm.pwm.log_odds(bg)\nprint(\'Got PSSM\')\nsl = len(pfm)\ni = 0\nt = time.time()\nfor pos, score in pssm.search(seq, threshold=7):\n    if abs(pos) >= i:\n        print(i, len(sites), time.time()-t)\n        i += 10000\n    if pos < 0:\n        strand = \'-\'\n        start = l+pos-sl          \n    else:\n        strand = \'+\'\n        start = pos\n    sites.append([start, start+sl, strand, score])\nsites = pd.DataFrame.from_records(sites, columns=[\'Start\', \'End\', \'Strand\', \'Score\'])\n')
    
    ~/anaconda3/envs/Hi-C/lib/python3.7/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
       2357             with self.builtin_trap:
       2358                 args = (magic_arg_s, cell)
    -> 2359                 result = fn(*args, **kwargs)
       2360             return result
       2361 
    
    </home/s1529682/anaconda3/envs/Hi-C/lib/python3.7/site-packages/decorator.py:decorator-gen-55> in prun(self, parameter_s, cell)
    
    ~/anaconda3/envs/Hi-C/lib/python3.7/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
        185     # but it's overkill for just that one bit of state.
        186     def magic_deco(arg):
    --> 187         call = lambda f, *a, **k: f(*a, **k)
        188 
        189         if callable(arg):
    
    ~/anaconda3/envs/Hi-C/lib/python3.7/site-packages/IPython/core/magics/execution.py in prun(self, parameter_s, cell)
        315             arg_str += '\n' + cell
        316         arg_str = self.shell.transform_cell(arg_str)
    --> 317         return self._run_with_profiler(arg_str, opts, self.shell.user_ns)
        318 
        319     def _run_with_profiler(self, code, opts, namespace):
    
    ~/anaconda3/envs/Hi-C/lib/python3.7/site-packages/IPython/core/magics/execution.py in _run_with_profiler(self, code, opts, namespace)
        337         prof = profile.Profile()
        338         try:
    --> 339             prof = prof.runctx(code, namespace, namespace)
        340             sys_exit = ''
        341         except SystemExit:
    
    ~/anaconda3/envs/Hi-C/lib/python3.7/cProfile.py in runctx(self, cmd, globals, locals)
         98         self.enable()
         99         try:
    --> 100             exec(cmd, globals, locals)
        101         finally:
        102             self.disable()
    
    <string> in <module>
    
    ~/Projects/biopython/Bio/motifs/matrix.py in search(self, sequence, threshold, both)
        420         for position in range(0, n - m + 1):
        421             s = sequence[position:position + m]
    --> 422             score = self.calculate(s)
        423             if score > threshold:
        424                 yield (position, score)
    
    ~/Projects/biopython/Bio/motifs/matrix.py in calculate(self, sequence)
        400         sequence = str(sequence)
        401         m = self.length
    --> 402         scores = _calculate(self.array, sequence, m)
        403 
        404         if len(scores) == 1:
    
    ~/Projects/biopython/Bio/motifs/matrix.py in _calculate(score_array, sequence, m)
         34 #        logodds = numpy.array([[score_dict[letter][i] for letter in "ACGT"]
         35 #                               for i in range(m)], float)
    ---> 36         _pwm.calculate(sequence, score_array, scores)
         37         return scores
         38 
    
    RuntimeError: position-weight matrix is not an array
  9. mdehoon commented on Nov 27, 2019

    @mdehoon
    Contributor

    I would suggest to rewrite the search function such that it calls self.calculate only once:

                scores = self.calculate(sequence)
    

    and then iterate over the scores. That should be much faster (but it will also use more memory).

  10. peterjc commented on Nov 27, 2019

    @peterjc
    Member

    Current code as in Biopython 1.75,

    $ time python issue2360.py 
    Got PSSM
    0 0 1.0530970096588135
    10000 2 2.1237728595733643
    20000 3 2.4396579265594482
    ...
    470000 207 82.13363480567932
    480000 210 83.69857096672058
    490000 211 84.0984787940979
    
    real	1m25.338s
    user	1m24.599s
    sys	0m0.357s
    

    With my tiny suggestion:

    $ time python issue2360.py 
    Got PSSM
    0 0 0.9792349338531494
    10000 2 1.9739890098571777
    20000 3 2.2687809467315674
    ...
    470000 207 77.44366097450256
    480000 210 78.97470903396606
    490000 211 79.36987805366516
    
    real	1m20.552s
    user	1m19.668s
    sys	0m0.374s
    

    Single run only, ~5s is a slight improvement - might be worth benching marking properly but doesn't seem to help much:

    $ git diff
    diff --git a/Bio/motifs/matrix.py b/Bio/motifs/matrix.py
    index 7dd5de127..ba82e8fba 100644
    --- a/Bio/motifs/matrix.py
    +++ b/Bio/motifs/matrix.py
    @@ -31,8 +31,9 @@ try:
             # Create the numpy arrays here; the C module then does not rely on numpy
             # Use a float32 for the scores array to save space
             scores = numpy.empty(n - m + 1, numpy.float32)
    -        logodds = numpy.array([[score_dict[letter][i] for letter in "ACGT"]
    -                               for i in range(m)], float)
    +        logodds = numpy.array(
    +            [[score_dict["A"][i], score_dict["C"][i], score_dict["G"][i], score_dict["T"][i]]
    +             for i in range(m)], float)
             _pwm.calculate(sequence, logodds, scores)
             return scores
     
    
  11. Phlya commented on Nov 27, 2019

    @Phlya
    ContributorAuthor

    I would suggest to rewrite the search function such that it calls self.calculate only once:

                scores = self.calculate(sequence)
    

    and then iterate over the scores. That should be much faster (but it will also use more memory).

    If calculate was a generator that would remove the memory issue! I don't know anything about C, would that be possible?

  12. peterjc commented on Nov 27, 2019

    @peterjc
    Member

    The following looks more promising,

    $ git diff
    diff --git a/Bio/motifs/matrix.py b/Bio/motifs/matrix.py
    index 7dd5de127..aff9736a2 100644
    --- a/Bio/motifs/matrix.py
    +++ b/Bio/motifs/matrix.py
    @@ -25,15 +25,13 @@ try:
         # the Python standard library instead of numpy arrays; this would still
         # allow us to use the C module.
     
    -    def _calculate(score_dict, sequence, m):
    +    def _calculate(logodds_array, sequence, m):
             """Calculate scores using C code (PRIVATE)."""
             n = len(sequence)
             # Create the numpy arrays here; the C module then does not rely on numpy
             # Use a float32 for the scores array to save space
             scores = numpy.empty(n - m + 1, numpy.float32)
    -        logodds = numpy.array([[score_dict[letter][i] for letter in "ACGT"]
    -                               for i in range(m)], float)
    -        _pwm.calculate(sequence, logodds, scores)
    +        _pwm.calculate(sequence, logodds_array, scores)
             return scores
     
     except ImportError:
    @@ -43,7 +41,7 @@ except ImportError:
             warnings.warn("Using pure-Python as missing Biopython's C code for PWM.",
                           BiopythonWarning)
     
    -    def _calculate(score_dict, sequence, m):
    +    def _calculate(logodds_array, sequence, m):
             """Calculate scores using Python code (PRIVATE).
     
             The C code handles mixed case so Python version must too.
    @@ -56,8 +54,9 @@ except ImportError:
                 for position in range(m):
                     letter = sequence[i + position]
                     try:
    -                    score += score_dict[letter][position]
    -                except KeyError:
    +                    # Is this correct?
    +                    score += logodds_array["ACGT".index(letter), position]
    +                except IndexError:
                         score = float("nan")
                         break
                 scores.append(score)
    @@ -398,7 +397,14 @@ class PositionSpecificScoringMatrix(GenericPositionMatrix):
             # case would impose an overhead to allocate the extra memory.
             sequence = str(sequence)
             m = self.length
    -        scores = _calculate(self, sequence, m)
    +        logodds_array = numpy.array(
    +            # Bypassing self.__getitem__ for speed!
    +            [[dict.__getitem__(self, "A")[i],
    +              dict.__getitem__(self, "C")[i],
    +              dict.__getitem__(self, "G")[i],
    +              dict.__getitem__(self, "T")[i]]
    +             for i in range(m)], float)
    +        scores = _calculate(logodds_array, sequence, m)
     
             if len(scores) == 1:
                 return scores[0]
    

    Using your test script ending as follows BTW,

    #sites = pd.DataFrame.from_records(sites, columns=['Start', 'End', 'Strand', 'Score'])
    if len(sys.argv) == 2:
        with open(sys.argv[1], "w") as handle:
            handle.write("# %i sites\n" % len(sites))
            for row in sites:
                handle.write("%s\n" % "\t".join(str(_) for _ in row))

    New:

    $ time python issue2360.py new.tsv
    Got PSSM
    0 0 0.3058328628540039
    10000 2 0.6215009689331055
    20000 3 0.7150938510894775
    ...
    470000 207 24.702112913131714
    480000 210 25.15814185142517
    490000 211 25.27655601501465
    
    real	0m25.744s
    user	0m25.438s
    sys	0m0.170s
    

    Old:

    $ time python issue2360.py old.tsv
    Got PSSM
    0 0 1.0405778884887695
    10000 2 2.105559825897217
    20000 3 2.4190919399261475
    ...
    470000 207 82.89175391197205
    480000 210 84.46706080436707
    490000 211 84.86971378326416
    
    real	1m25.798s
    user	1m24.790s
    sys	0m0.343s
    

    Confirming no change in the output:

    $ diff old.tsv new.tsv
    

    Not bad, about a fifth of the run time.

    Note: I have not checked the pure Python version actually still works.

    Do you like this approach @mdehoon? This has the advantage of not changing the public API at all.

  13. peterjc commented on Nov 27, 2019

    @peterjc
    Member

    I don't know this code well enough to comment on the generator idea without a lot more work - my change is very targeted, avoiding the hot-spot of the matrix class __getitem__ @phyla identifier by benchmarking. Essentially that is a big if/else statement to decide how to handle various index arguments - since in this context we know the exact arguments in advance, and can do the appropriate look up directly.

  14. Phlya commented on Nov 27, 2019

    @Phlya
    ContributorAuthor

    That looks really good! This still creates a new array for each position, is it possible to calculate it just once and store? I'd expect it to be even faster then, although not sure this would still be the bottleneck after your change.

  15. peterjc commented on Nov 27, 2019

    @peterjc
    Member

    With a slight refactoring I think yes, the .search() call could define the array once for the duration of the search, do the alphabet check and call ._calculate() directly (bypassing .calculate() which can remain as a public API).

    Update: I'm not currently clear enough on how the reverse-complement is being handled in the search to try that...

  16. 3 remaining items

  17. peterjc commented on Nov 28, 2019

    @peterjc
    Member

    Perhaps the motifs code should raise a TypeError when given a SeqRecord, or do the expected thing and use the .seq attribute automatically?

  18. Phlya commented on Nov 28, 2019

    @Phlya
    ContributorAuthor

    Ah of course, thank you! I would have expected this to raise an error?..

  19. Phlya commented on Nov 28, 2019

    @Phlya
    ContributorAuthor

    And it does work super quickly!

  20. Phlya commented on Nov 28, 2019

    @Phlya
    ContributorAuthor

    But indeed, simply applying .calculate() to a whole chromosome leads to MemoryError on my machine.

  21. mdehoon commented on Nov 28, 2019

    @mdehoon
    Contributor

    @Phlya

    But indeed, simply applying .calculate() to a whole chromosome leads to MemoryError on my machine.

    Then you could modify the search function such that the sequence is divided into segments, and search each separately. If the segments are long enough (maybe 100,000 bp or so), the code will still be fast while memory usage will stay low.

  22. Phlya commented on Nov 28, 2019

    @Phlya
    ContributorAuthor

    Exactly what I am writing now

  23. Phlya commented on Nov 28, 2019

    @Phlya
    ContributorAuthor
    def my_search(pssm, seq, threshold, chunksize=10**6):
        cols = ['chrom', 'start', 'end', 'strand', 'score']
        l = len(seq)
        chunk_starts = np.arange(0, l, chunksize)
        allscores = []
        for chunk_start in chunk_starts:
            subseq = seq[chunk_start:chunk_start+chunksize]
            scores = pssm.calculate(subseq)
            positions = np.where(scores>=threshold)[0]
            possites = pd.DataFrame(columns=cols)
            if len(positions)>0:
                possites[cols] = pd.DataFrame([[chrom]*len(positions), positions+chunk_start, positions+len(pssm)+chunk_start, ['+']*len(positions), scores[positions]]).T
            
            scores = pssm.reverse_complement().calculate(subseq)
            positions = np.where(scores>=threshold)[0]
            
            negsites = pd.DataFrame(columns=cols)
            if len(positions)>0:
                negsites[cols] = pd.DataFrame([[chrom]*len(positions), positions+chunk_start, positions+len(pssm)+chunk_start, ['-']*len(positions), scores[positions]]).T
            
            allscores.append(pd.concat([possites, negsites]))
        return pd.concat(allscores)

    Here is the function that works for me. It uses pandas, which I think is not a biopython dependency? I am however happy for it to be adapted to replace the .search() method.

  24. mdehoon commented on Nov 29, 2019

    @mdehoon
    Contributor

    @Phlya Indeed, pandas is not a biopython dependency.
    Would you be able to create a pull request with the code to replace the .search() method in Biopython?

  25. Phlya commented on Nov 30, 2019

    @Phlya
    ContributorAuthor

    Ok, this implementation, actually, will miss motifs on the edges of chunks, I'll have to modify it a little. Otherwise, yes, I can create a PR, perhaps, on Monday.

  26. mdehoon commented on Nov 30, 2019

    @mdehoon
    Contributor

    @Phlya Great, thanks!

  27. Phlya commented on Dec 5, 2019

    @Phlya
    ContributorAuthor

    Sorry, I've been sick for a few days and accumulated some relatively urgent things I need to do at work, but I remember about this.

  28. Phlya commented on Dec 6, 2019

    @Phlya
    ContributorAuthor

    #2386 here is the PR, let me know what you think. It relies heavily on numpy, but assume that is OK

  29. mdehoon commented on Dec 22, 2019

    @mdehoon
    Contributor

    As #2386 has been accepted, can we close this issue?

  30. peterjc commented on Dec 23, 2019

    @peterjc
    Member

    Probably this can be closed, yes.

    Is there any need to merge #2361 as well, or can that be closed too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions