62 Commits

Author SHA1 Message Date
5d04966f6c remove deprecated code from Bio.motifs (#4915)
Co-authored-by: Michiel Jan Laurens de Hoon <mdehoon@Michiels-MacBook-Air.local>
2025-01-17 10:48:06 +09:00
ac616465bc Allow writing clusterbuster motif files with float values instead of only integers.
Although not shown on the ClusterBuster motif format page:
  https://bu.wenglab.org/cluster-buster/help/cis-format.html
Cluster-Buster supports reading Cluster-Buster motif files with float
values as opposed to integer values, just fine.

By default integer values are written

  motifs.write(motifs, "clusterbuster")

but when precision different from 0 is specified, float values will be written:

  motifs.write(motifs, "clusterbuster", precision=2)
2024-08-12 16:20:55 +01:00
bc0d58b4c4 Add support for reading GAP and WEIGHT parameters from Cluster Buster motif file. 2024-08-12 16:20:55 +01:00
f02217c40e Improve minimal meme format parsing (#4787)
* Support degenerate consensus sequences for RNA motifs.

Support degenerate consensus sequences for RNA motifs.

* Support parsing minimal MEME files with RNA motifs and motifs without all statistcs provided in the letter-probability matrix line.

Support parsing minimal MEME RNA motif files.
Support parsing mininal MEME motif files where not all statistics
are provided in the "letter-probability matrix:" line:
  - As seen in the minimal MEME motif file specification:
    http://web.mit.edu/meme/current/share/doc/meme-format.html#min_motif_pspm
    a "letter-probability matrix:" line is required, but all the "key= value"
    pairs after the "letter-probability matrix:" text are optional.
  - The "alength= alphabet length" and "w= motif length" can be derived from
    the matrix if they are not specified, provided there is an empty line
    following the letter probability matrix.
  - The "nsites= source sites" will default to 20 if it is not provided and
    the "E= source E-value" will default to zero.
  - It is relatively common to find minimal MEME motif files without E-value:
    For example, HOCOMOCO v11 minimal MEME file:
      https://hocomoco11.autosome.org/final_bundle/hocomoco11/core/HUMAN/mono/HOCOMOCOv11_core_HUMAN_mono_meme_format.meme
2024-08-09 23:20:35 +09:00
d398dfacaa Fix assertAlmostEqual calls in tests, when checking for very small numbers in scientific notation. (#4770)
Fix assertAlmostEqual calls in tests, when checking for very small numbers
in scientific notation by adding "places" parameter with enough precision.

This mostly affects comparing E-values between test files and parsing of
those files. Quite some cases were actually checking for the wrong value.
2024-07-20 08:48:52 +09:00
91d364164c Support reverse complementing RNA motifs. (#4771)
Support reverse complementing RNA motifs.
2024-07-20 08:45:23 +09:00
c2ba43db03 Add support for reading PFM from Cys2His2 Zinc Finger Proteins PWM Predictor. (#4693)
* Add support for reading PFM from Cys2His2 Zinc Finger Proteins PWM Predictor.

Add support for reading PFM from Cys2His2 Zinc Finger Proteins PWM Predictor
(http://zf.princeton.edu/logoMain.php).

* Capitilize motif subtypes for "pfm-four-columns" and "pfm-four-rows" correctly.

Capitilize motif subtypes for "pfm-four-columns" and "pfm-four-rows" correctly.

* Set empty motif name string when no motif name is found when reading PFM files in "pfm-four-columns" format.

Set empty motif name string when no motif name is found when
reading PFM files in "pfm-four-columns" format.

* Add reading PFM in "pfm-four-columns" and "pfm-four-rows" to motifs tutorial.

Add reading PFM in "pfm-four-columns" and "pfm-four-rows" to motifs tutorial.
2024-06-30 09:52:02 +09:00
de0bb21fb3 Apply isort (forcing single lines, not sorting by type) via ruff
$ ruff check --fix --select=I \
  --config=lint.isort.force-single-line=true \
  --config=lint.isort.order-by-type=false \
  BioSQL/ Bio/ Tests/ Scripts/ Doc/ setup.py

Using ruff version 0.4.10
2024-06-26 15:31:39 +09:00
f40d6b7aa7 ruff fix most F401 unused imports in Tests
(base) Peters-iMac:biopython pc40583$ ruff check --fix --select F401 Tests/ --exclude "Tests/common_BioSQL_online.py,Tests/seq_tests_common.py,Tests/test_SearchIO_blast_text.py,Tests/test_codonalign.py,Tests/test_Cluster.py,Tests/test_codonalign.py"
...
Found 82 errors (54 fixed, 28 remaining)
2023-11-02 09:34:48 +00:00
68e3c989d9 ruff fix PIE790 Unnecessary pass statement
$ ruff --fix --select PIE790 BioSQL/ Bio/ Doc/examples/ Tests/ Scripts/
Found 62 errors (62 fixed, 0 remaining).

Then re-ran black.
2023-11-02 09:34:48 +00:00
e812f38bfb replace numpy by np in some test scripts (#4418)
* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

---------

Co-authored-by: Michiel de Hoon <mdehoon@madpc2s-MacBook-Pro.local>
2023-08-14 18:31:48 +09:00
2a3d305cb4 Bio.motifs: add relative entropy to the Motif class (#4362)
* update

* update

* update

* update

* update

* update
2023-07-20 00:24:17 +09:00
2dab6a9eeb update (#4359) 2023-07-15 00:15:38 +09:00
c0f9bd521a Motif getindex (#4358)
* update

* update

* update

* update

* update

* update

---------

Co-authored-by: Michiel de Hoon <mdehoon@tkx249.genome.gsc.riken.jp>
2023-07-14 18:32:07 +09:00
72bdcd2510 Deprecate Bio.motifs.Instances (#4340)
* update

* update

* update

* update

* update

---------

Co-authored-by: Michiel de Hoon <mdehoon@tkx249.genome.gsc.riken.jp>
2023-07-05 17:43:20 +09:00
763332f10f f-strings with flynt v0.69 on Tests/ 2021-09-20 10:54:38 +01:00
d1d9c70948 replace isinstance(int) by isinstance(numbers.Integral) (#3642)
* replace isinstance(int) by isinstance(numbers.Integral) for obvious cases

* add tests

* style
2021-06-28 22:08:08 +09:00
eb28a23146 Use a format method instead of the format function (#3521)
* undeprecate format

* remove temporary hack

* fix DEPRECATED.rst

* add docstring

* don't deprecate __format__

* remove imports

* remove warnings import
2021-04-07 22:00:06 +09:00
058c503b1b Add tests for "pfm-four-columns" and "pfm-four-rows" motif formats.
Add tests for "pfm-four-columns" and "pfm-four-rows" motif formats.
2021-03-19 16:05:41 +00:00
194df4e5c6 remove unnecessary str (#3392) 2020-11-27 13:09:40 +09:00
25c91b47c3 Remove overlooked Bio.Alphabet usage 2020-07-29 08:55:20 +01:00
9c663d12bc removed alphabets (#3047) 2020-07-13 18:07:12 +09:00
2db8022383 remove old-style alphabets from Bio.motifs (#2939)
* remove old-style alphabets from Bio.motifs

* remove alphabets from test_motifs.py
2020-06-02 11:54:19 +09:00
373e5b2a3d Dropped Gapped class from most testing 2020-05-29 21:06:29 +01:00
07d430b5c9 Apply black style to test_m* files, version 19.10b0.
test_Mafft_tool.py
test_MafIO_index.py
test_MarkovModel.py
test_Medline.py
test_mmtf.py
test_mmtf_online.py
test_motifs.py
test_motifs_online.py
test_MSAProbs_tool.py
test_Muscle_tool.py
2020-05-26 15:03:09 +01:00
d930695571 Use XML parsing for MEME output files (#2354)
* Implement XML parsing for MEME

Update parser to work with XML rather than plain-text MEME output.
This commit retains the functionality of the current parser.
TODO's are added where more information can be parsed with XML.

* Fix instance start value

* Update MEME test case 3 with XML file

* Add function to convert strand (+/-)

* Fix stand for MEME test case 3

* Update MEME test case 3 with XML file

* Remove abandoned MEME test files

* Minor formatting fixes

* Update MEME test case 4 with XML file

* Remove MEME tests 1, 4, 4_11_4, RNA

TODO:
- add test for -rna option
- add tests for other MEME versions supporting XML output

* Update docstring examples

* Fix docstring styling

* Update NEWS.rst

* Update parse error

* Remove .html and .txt test files

* Remove abandoned MEME test files

* Rename function

* Update with sequence_id, sequence_name

Use dictionary to store map of sequence id : name
since name is not included under the instances tree

* Update copyright headers

* Update docstring example

* Update docstring example, add test file with 1 motif

* Update motifs documentation inline examples

* Restore meme.out

Used in Bio.motifs.minimal.read() docstring example

* Apply black style to meme.py
2020-04-01 09:12:28 +09:00
d1969c4ec2 use with statement in test_motifs (#2684) 2020-02-11 12:40:49 +09:00
75d198f4e0 replace the format method with __format__ (#2493)
* replaced the format method with __format__

* trivial change to restart travis

* noqa to find out what makes travis sad

* travis is having a bad day

* doctest updates

* travis false negative

* fix doctest typo

* fix doctest typo

* now we're getting somewhere

* update tests to silence warning

* one more old format
2020-01-07 22:24:07 +09:00
ced144eb01 Fix bug motif reverse complement (#2387)
* be sure to go through __init__ to be sure that the Motif is initialized appropriately

* fix attributes

* travis
2019-12-07 19:07:27 +09:00
7da1c6413c Fixes motifs.jaspar.calculate_pseudocounts (#2384) 2019-12-06 13:59:42 +00:00
1b9e569a7f Using tool unify to convert Tests/ to use double quotes
Using https://github.com/myint/unify for this:

$ unify --quote \" --in-place Tests/*.py Tests/*/*.py
2019-08-02 14:10:22 +01:00
b920c5ccf1 Use XML parsing for MAST output files (#2082)
Closes issue #1980

Replaced the old text MAST output parser which was written for:

MAST version 3.0 (Release date: 2004/08/18 09:07:01)

Instead the new parser expects MAST XML output.

Test cases updated using http://meme-suite.org/meme-software/5.0.5/meme-5.0.5.tar.gz
2019-06-03 11:43:39 +01:00
49892b2479 update (#2066) 2019-05-23 17:18:39 +09:00
ce904f7bfe Update references to Motif -> motifs 2019-05-20 10:10:26 +01:00
ebee2eb152 Dual license Tests/test_motifs.py
Original authors Bartek Wilczynski (CVS username bartek, on GitHub as @barwil)
and Jeff Chang (CVS username jchang, on GitHub as @jefftc) and other contributors
since have agreed:

 - Antony Lee (@anntzer)
   https://github.com/biopython/biopython/issues/898#issuecomment-236969803
 - Ariel Aptekmann (@aralap)
   https://github.com/biopython/biopython/pull/1734
 - bartek (@barwil)
   http://mailman.open-bio.org/pipermail/biopython/2018-August/016533.html
 - Bertrand Néron (@bneron)
   https://github.com/biopython/biopython/issues/898#issuecomment-236928092
 - Wibowo Arindrarto (@bow)
   https://github.com/biopython/biopython/issues/898#issuecomment-236920576
 - Christian Brueffer (@cbrueffer)
   https://github.com/biopython/biopython/issues/898#issuecomment-236922857
 - Gert Hulselmans (@ghuls)
   https://github.com/biopython/biopython/issues/898#issuecomment-236995038
 - Jared Andrews (@j-andrews7)
   https://github.com/biopython/biopython/issues/898#issuecomment-333637841
 - Jeff Chang (@jefftc)
   https://github.com/biopython/biopython/issues/898#issuecomment-236968522
 - Michiel de Hoon (@mdehoon)
   https://github.com/biopython/biopython/issues/898#issuecomment-237122630
 - Peter Cock (@peterjc)
   https://github.com/biopython/biopython/issues/898#issue-167420613
 - Zaid Ur-Rehman (@zaidurrehman)
   https://github.com/biopython/biopython/pull/867
2019-05-16 16:02:14 +01:00
70f6347afa add xms parsing test 2019-05-16 16:02:14 +01:00
7be083787c fix whitespace parsing and test 2019-05-16 16:02:14 +01:00
c4d7694922 add clusterbuster motif support 2019-05-16 16:02:14 +01:00
e4fc1f9511 flake8 E241 - fixed with autopep8
autopep8 -i --select E241 *.py
2019-04-23 10:35:56 +01:00
846c8f1cc6 flake8 D100: Automatically added docstrings
Done with the following ad-hoc script:

"""In-place fix for D100 Missing docstring in public module."""
import os
import sys

def fix(lines, docstring):
    answer = []
    # 0 = preamble
    # 1 = waiting for it
    # 2 = seen module docstring
    state = 0
    for line in lines:
        if state == 0 and line.startswith("#") or not line.strip():
            # hashbang or licence block
            pass
        elif state == 0 and line.lstrip().startswith('"""'):
            state = 2
        elif state == 2:
            pass
        else:
            # Insert docstring
            answer.append('"""%s"""\n\n' % docstring)
            state = 2
        answer.append(line)
    return answer

for f in sys.argv[1:]:
    print(f)
    with open(f) as handle:
        old = list(handle)
    name = os.path.basename(f)
    assert name.endswith(".py")
    name = name[:-3].replace("_", " ")
    if name.startswith("test "):
        name = "Tests for %s" % name[5:]
    if not name.endswith(" tool"):
        name += " module"
    new = fix(old, name + ".")
    with open(f, "w") as handle:
        for line in new:
            handle.write(line)
print("Done")
2019-04-23 10:27:31 +01:00
ec994b433d In the TRANSFAC parser, don't issue warnings if strict is False (#1892)
* skip warnings if strict is False

* use ValueError instead of warnings

* update documentation

* adding a unit test

* make travis happy
2019-02-03 04:37:25 +09:00
110178f541 Update init.py to include minimal meme support
Directs to new minimal parser. Includes tests.
2018-11-23 13:44:05 +00:00
31051a8e76 sample file and tests for meme rna parsing 2017-10-24 18:24:40 +01:00
fc510dc051 Update MEME parser (v4.11.4 support)
Included new test case.

Squashed commit of pull request #1266.
2017-06-20 16:24:13 +01:00
d2eaef4a64 test_motifs.py docstrings 2017-06-13 15:03:47 +01:00
03f2b6953a Check a motif error condition
Ideally could we support making motifs of similar alphabets?
2016-05-31 12:39:36 +01:00
6b75d8cc8b Follow up for removing old workaround 2015-10-30 16:09:53 +00:00
98ad63d20d Make Bio.motifs weblogo test respect run_tests.py --offline 2015-09-11 17:10:17 +01:00
9b09b75f31 Fix motif weblogo for Python3, closes #475.
Includes test.
2015-09-11 17:01:10 +01:00
cb0665c951 replace assertRaisesRegexp by a assertRaises
as assertRaisesRegexp does not exist in 2.6
2015-08-10 14:48:29 +02:00