aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMunyoki Kilyungi2022-09-05 11:16:53 +0300
committerBonfaceKilz2022-09-08 14:26:19 +0300
commit3f7924fb8e2d2abfb49cdc458149d00a603f7d97 (patch)
tree5d8c9c4892dc50e1850d6ea09aec5eec11761980 /doc
parente4c0ee8816e9b09d162354c2cde511ef7a527298 (diff)
downloadgenenetwork2-3f7924fb8e2d2abfb49cdc458149d00a603f7d97.tar.gz
Replace "g.db" with "database_connection" in documentation
Diffstat (limited to 'doc')
-rw-r--r--doc/database.org22
1 files changed, 12 insertions, 10 deletions
diff --git a/doc/database.org b/doc/database.org
index 32f1f8e0..315ee2b6 100644
--- a/doc/database.org
+++ b/doc/database.org
@@ -1327,16 +1327,18 @@ we list the Published entries.
The SNP count info for the BXD is calculated like this
#+begin_src python
- while startMb<endMb:
- snp_count = g.db.execute("""
- select
- count(*) from BXDSnpPosition
- where
- Chr = '%s' AND Mb >= %2.6f AND Mb < %2.6f AND
- StrainId1 = %d AND StrainId2 = %d
- """ % (chrName, startMb, startMb+stepMb, strainId1, strainId2)).fetchone()[0]
- SNPCounts.append(snp_count)
- startMb += stepMb
+ with database_connection() as conn, conn.cursor() as cursor:
+ while startMb < endMb:
+ # snp count
+ cursor.execute(
+ "SELECT COUNT(*) FROM BXDSnpPosition "
+ "WHERE CHr = %s AND Mb >= %s AND Mb < %s "
+ "AND StrainId1 = %s AND StrainId2 = %s",
+ (chrName, f"{startMb:2.6f}", f"{startMb+stepMb:2.6f}",
+ strainId1, strainId2,)
+ )
+ SNPCounts.append(cursor.fetchone()[0])
+ startMB += stepMb
#+end_src
: select * from BXDSnpPosition limit 5;