Skip to content

Commit

Permalink
Add test for csv2db (#360)
Browse files Browse the repository at this point in the history
*  revert #358 and add small test for csv2db

*  pep8

* avoid using customised .sqliterc for sqlite output
  • Loading branch information
sebastian-luna-valero authored Sep 22, 2017
1 parent 45cf0ca commit b74b75d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions CGAT/CSV2DB.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,7 @@ def row_iter(rows, reader):

while 1:
try:
if isinstance(dbhandle, str):
dbhandle.executemany(statement, data)
dbhandle.executemany(statement, data)
except error as msg:
E.warn("import failed: msg=%s, statement=\n %s" %
(msg, statement))
Expand Down
2 changes: 2 additions & 0 deletions tests/csv2db.py/csvdb.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
|transcribed_unprocessed_pseudogene|ENSG00000223972|DDX11L1|havana|5|OTTHUMG00000000961|2|OTTHUMT00000362751|1|basic|processed_transcript|havana|1|2
1|transcribed_unprocessed_pseudogene|ENSG00000223972|DDX11L1|havana|5|OTTHUMG00000000961|2|OTTHUMT00000362751|1|basic|processed_transcript|havana|1|2
3 changes: 3 additions & 0 deletions tests/csv2db.py/table.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gene_id exon_version gene_biotype gene_name gene_source gene_version havana_gene havana_gene_version havana_transcript havana_transcript_version tag transcript_biotype transcript_source transcript_support_level transcript_version
ENSG00000223972 transcribed_unprocessed_pseudogene DDX11L1 havana 5 OTTHUMG00000000961 2 OTTHUMT00000362751 1 basic processed_transcript havana 1 2
ENSG00000223972 1 transcribed_unprocessed_pseudogene DDX11L1 havana 5 OTTHUMG00000000961 2 OTTHUMT00000362751 1 basic processed_transcript havana 1 2
6 changes: 6 additions & 0 deletions tests/csv2db.py/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ version:
outputs: [stdout]
references: []
options: --version

simple_query:
stdin: table.csv
outputs: [stdout]
references: [csvdb.ref]
options: --retry --database-backend=sqlite --database-name=csvdb --table=gene_info -L /dev/null -S /dev/null -E /dev/null && sqlite3 <TMP>/csvdb "select * from gene_info;" 2> /dev/null

0 comments on commit b74b75d

Please sign in to comment.