Mercurial > repos > greg > ensure_synced
comparison ensure_synced.py @ 7:59edc91d0bea draft
Uploaded
author | greg |
---|---|
date | Fri, 17 Dec 2021 17:55:08 +0000 |
parents | 68ca17b451f2 |
children | aaa6ae7c64de |
comparison
equal
deleted
inserted
replaced
6:68ca17b451f2 | 7:59edc91d0bea |
---|---|
3 | 3 |
4 import argparse | 4 import argparse |
5 import sys | 5 import sys |
6 | 6 |
7 import psycopg2 | 7 import psycopg2 |
8 | 8 from sqlalchemy import create_engine |
9 from sqlalchemy import MetaData | 9 from sqlalchemy import MetaData |
10 from sqlalchemy import create_engine | |
11 from sqlalchemy.engine.url import make_url | 10 from sqlalchemy.engine.url import make_url |
12 | 11 |
13 metadata = MetaData() | 12 metadata = MetaData() |
14 | 13 |
15 SKIP_VALS = ['#CHROM', 'POS', 'ID', 'REF', 'ALT', 'QUAL', 'FILTER', 'INFO', 'FORMAT'] | 14 SKIP_VALS = ['#CHROM', 'POS', 'ID', 'REF', 'ALT', 'QUAL', 'FILTER', 'INFO', 'FORMAT'] |
33 args.update(url.query) | 32 args.update(url.query) |
34 assert url.get_dialect().name == 'postgresql', 'This script can only be used with PostgreSQL.' | 33 assert url.get_dialect().name == 'postgresql', 'This script can only be used with PostgreSQL.' |
35 self.conn = psycopg2.connect(**args) | 34 self.conn = psycopg2.connect(**args) |
36 | 35 |
37 def get_affy_ids_from_db(self): | 36 def get_affy_ids_from_db(self): |
38 cmd = "SELECT coral_mlg_rep_sample_id, coral_mlg_clonal_id FROM genotype WHERE coral_mlg_rep_sample_id IS NOT NULL AND coral_mlg_rep_sample_id != '' AND coral_mlg_clonal_id != 'failed' ORDER BY coral_mlg_rep_sample_id;” | 37 cmd = "SELECT coral_mlg_rep_sample_id, coral_mlg_clonal_id FROM genotype WHERE coral_mlg_rep_sample_id IS NOT NULL AND coral_mlg_rep_sample_id != '' AND coral_mlg_clonal_id != 'failed' ORDER BY coral_mlg_rep_sample_id;" |
39 cur = self.conn.cursor() | 38 cur = self.conn.cursor() |
40 cur.execute(cmd) | 39 cur.execute(cmd) |
41 rows = cur.fetchall() | 40 rows = cur.fetchall() |
42 for row in rows: | 41 for row in rows: |
43 self.affy_ids_from_db.append(row[0]) | 42 self.affy_ids_from_db.append(row[0]) |