Skip to content

Commit 4e4f6cc

Browse files
committed
fixed case sensitive search
1 parent ae5a25b commit 4e4f6cc

File tree

9 files changed

+602
-43
lines changed

9 files changed

+602
-43
lines changed

.DS_Store

0 Bytes
Binary file not shown.

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
pyJASPAR
22
--------
33

4-
A serverless interface to Biopython to query and access JASPAR motifs from different releases of JASPAR database using sqlite3.
4+
A serverless interface to Biopython to query and access JASPAR motifs from different releases of JASPAR database using sqlite3.
5+
6+
57
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.4485857.svg
68
:target: https://doi.org/10.5281/zenodo.4485857
79

8-
910
.. image:: https://travis-ci.org/asntech/pyjaspar.svg?branch=main
1011
:target: https://travis-ci.org/asntech/pyjaspar
1112

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
author = 'Aziz Khan'
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = 'v1.5.0'
25+
release = 'v1.5.5'
2626

2727

2828
# -- General configuration ---------------------------------------------------

pyjaspar/__init__.py

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
for motif in motifs:
4343
pass # do something with the motif
4444
"""
45-
__version__ = '1.5.0'
45+
__version__ = '1.5.5'
4646

4747

4848
import warnings
@@ -325,7 +325,7 @@ def _fetch_internal_id(self, base_id, version):
325325
Also checks if this combo exists or not.
326326
"""
327327
cur = self.conn.cursor()
328-
cur.execute("select id from MATRIX where BASE_id = ? and VERSION = ?", (base_id, version))
328+
cur.execute("select id from MATRIX where BASE_id = ? and VERSION = ? COLLATE NOCASE", (base_id, version))
329329

330330
row = cur.fetchone()
331331

@@ -344,7 +344,7 @@ def _fetch_internal_id(self, base_id, version):
344344
def _fetch_motif_by_internal_id(self, int_id):
345345
"""Fetch basic motif information (PRIVATE)."""
346346
cur = self.conn.cursor()
347-
cur.execute("SELECT BASE_ID, VERSION, COLLECTION, NAME FROM MATRIX WHERE ID = ?", (int_id,))
347+
cur.execute("SELECT BASE_ID, VERSION, COLLECTION, NAME FROM MATRIX WHERE ID = ? COLLATE NOCASE", (int_id,))
348348

349349
row = cur.fetchone()
350350

@@ -387,7 +387,7 @@ def _fetch_motif_by_internal_id(self, int_id):
387387
motif.species = tax_ids
388388

389389
# fetch protein accession numbers
390-
cur.execute("select ACC FROM MATRIX_PROTEIN where id = ?", (int_id,))
390+
cur.execute("select ACC FROM MATRIX_PROTEIN where id = ? COLLATE NOCASE", (int_id,))
391391
accs = []
392392
rows = cur.fetchall()
393393
for row in rows:
@@ -516,7 +516,7 @@ def _fetch_internal_id_list(
516516
for id in matrix_id:
517517
# ignore vesion here, this is a stupidity filter
518518
(base_id, version) = jaspar.split_jaspar_id(id)
519-
cur.execute("select ID from MATRIX where BASE_ID = ?", (base_id,))
519+
cur.execute("select ID from MATRIX where BASE_ID = ? COLLATE NOCASE", (base_id,))
520520

521521
rows = cur.fetchall()
522522
for row in rows:
@@ -546,12 +546,13 @@ def _fetch_internal_id_list(
546546
if isinstance(collection, list):
547547
# Multiple collections passed in as a list
548548
clause = "m.COLLECTION in ('"
549-
clause = "".join([clause, "','".join(collection)])
549+
clause = "".join([clause, "','".join([c.upper() for c in collection])])
550550
clause = "".join([clause, "')"])
551551
else:
552552
# A single collection - typical usage
553-
clause = "m.COLLECTION = '%s'" % collection
554-
553+
clause = "m.COLLECTION = '%s'" % collection.upper()
554+
##SQLite is case sensitive therefore COLLATE NOCASE is set.
555+
#clause = "%s COLLATE NOCASE" % clause
555556
where_clauses.append(clause)
556557

557558
# Select by MATRIX.NAME
@@ -564,7 +565,8 @@ def _fetch_internal_id_list(
564565
else:
565566
# A single name
566567
clause = "m.NAME = '%s'" % tf_name
567-
568+
##SQLite is case sensitive therefore COLLATE NOCASE is set.
569+
#clause = "%s COLLATE NOCASE" % clause
568570
where_clauses.append(clause)
569571

570572
# Select by MATRIX_SPECIES.TAX_ID
@@ -584,7 +586,8 @@ def _fetch_internal_id_list(
584586
else:
585587
# A single tax ID
586588
clause = "ms.TAX_ID = '%s'" % str(species)
587-
589+
##SQLite is case sensitive therefore COLLATE NOCASE is set.
590+
#clause = "%s COLLATE NOCASE" % clause
588591
where_clauses.append(clause)
589592

590593
"""
@@ -623,7 +626,8 @@ def _fetch_internal_id_list(
623626
else:
624627
# A single TF class
625628
clause = "".join([clause, " and ma1.VAL = '%s' " % tf_class])
626-
629+
##SQLite is case sensitive therefore COLLATE NOCASE is set.
630+
#clause = "%s COLLATE NOCASE" % clause
627631
where_clauses.append(clause)
628632

629633
# Select by TF families (MATRIX_ANNOTATION.TAG="family")
@@ -640,7 +644,8 @@ def _fetch_internal_id_list(
640644
else:
641645
# A single TF family
642646
clause = "".join([clause, " and ma2.VAL = '%s' " % tf_family])
643-
647+
##SQLite is case sensitive therefore COLLATE NOCASE is set.
648+
#clause = "%s COLLATE NOCASE" % clause
644649
where_clauses.append(clause)
645650

646651
# Select by PAZAR TF ID(s) (MATRIX_ANNOTATION.TAG="pazar_tf_id")
@@ -657,7 +662,8 @@ def _fetch_internal_id_list(
657662
else:
658663
# A single PAZAR ID
659664
clause = "".join([" and ma3.VAL = '%s' " % pazar_id])
660-
665+
##SQLite is case sensitive therefore COLLATE NOCASE is set.
666+
#clause = "%s COLLATE NOCASE" % clause
661667
where_clauses.append(clause)
662668

663669
# Select by PubMed ID(s) (MATRIX_ANNOTATION.TAG="medline")
@@ -674,7 +680,8 @@ def _fetch_internal_id_list(
674680
else:
675681
# A single PubMed ID
676682
clause = "".join([" and ma4.VAL = '%s' " % medline])
677-
683+
##SQLite is case sensitive therefore COLLATE NOCASE is set.
684+
#clause = "%s COLLATE NOCASE" % clause
678685
where_clauses.append(clause)
679686

680687
# Select by data type(s) used to compile the matrix
@@ -692,7 +699,8 @@ def _fetch_internal_id_list(
692699
else:
693700
# A single data type
694701
clause = "".join([" and ma5.VAL = '%s' " % data_type])
695-
702+
##SQLite is case sensitive therefore COLLATE NOCASE is set.
703+
#clause = "%s COLLATE NOCASE" % clause
696704
where_clauses.append(clause)
697705

698706
# Select by taxonomic supergroup(s) (MATRIX_ANNOTATION.TAG="tax_group")
@@ -704,20 +712,23 @@ def _fetch_internal_id_list(
704712
if isinstance(tax_group, list):
705713
# A list of tax IDs
706714
clause = "".join([clause, " and ma6.VAL in ('"])
707-
clause = "".join([clause, "','".join(tax_group)])
715+
clause = "".join([clause, "','".join([tg.lower() for tg in tax_group])])
708716
clause = "".join([clause, "')"])
709717
else:
710718
# A single tax ID
711-
clause = "".join([clause, " and ma6.VAL = '%s' " % tax_group])
712-
719+
clause = "".join([clause, " and ma6.VAL = '%s' " % tax_group.lower()])
720+
##SQLite is case sensitive therefore COLLATE NOCASE is set.
721+
#clause = "%s COLLATE NOCASE" % clause
713722
where_clauses.append(clause)
714723

715724
sql = "".join(["select distinct(m.ID) from ", ", ".join(tables)])
716725

717726
if where_clauses:
718727
sql = "".join([sql, " where ", " and ".join(where_clauses)])
719728

720-
# print "sql = %s" % sql
729+
### SQLite is casesensitivitive
730+
sql = "%s COLLATE NOCASE" % sql
731+
#print(sql)
721732

722733
cur.execute(sql)
723734
rows = cur.fetchall()
@@ -747,7 +758,7 @@ def _is_latest_version(self, int_id):
747758

748759
cur.execute("select count(*) from MATRIX where "
749760
"BASE_ID = (select BASE_ID from MATRIX where ID = ?) "
750-
"and VERSION > (select VERSION from MATRIX where ID = ?)",
761+
"and VERSION > (select VERSION from MATRIX where ID = ?) COLLATE NOCASE",
751762
(int_id, int_id))
752763

753764
row = cur.fetchone()

pyjaspar/data/JASPAR2014.sqlite

567 KB
Binary file not shown.

pyjaspar/data/JASPAR2016.sqlite

566 KB
Binary file not shown.

pyjaspar/data/JASPAR2018.sqlite

600 KB
Binary file not shown.

pyjaspar/data/JASPAR2020.sqlite

632 KB
Binary file not shown.

0 commit comments

Comments
 (0)