From ed2faea2f7d14b03ded174532fd919414e65a60e Mon Sep 17 00:00:00 2001 From: Markus Ankenbrand Date: Wed, 1 Mar 2017 10:09:44 +0100 Subject: [PATCH 1/3] Try to create dbxref and cvterm for every line of mapman. Add compatibility with new file format version. --- .../commands/Importer_Annotations_MapMan.php | 97 +++++++++++-------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/src/cli/import/commands/Importer_Annotations_MapMan.php b/src/cli/import/commands/Importer_Annotations_MapMan.php index 2709d534..080819f5 100644 --- a/src/cli/import/commands/Importer_Annotations_MapMan.php +++ b/src/cli/import/commands/Importer_Annotations_MapMan.php @@ -7,6 +7,9 @@ class Importer_Annotations_MapMan extends Importer_Annotations_Dbxref { + private static $dbxrefs = array(); + private static $cvterms = array(); + /** * @inheritDoc */ @@ -97,27 +100,7 @@ public static function import($options) { */ $stm_link_dbxref = $db->prepare('INSERT INTO feature_dbxref (feature_id, dbxref_id) VALUES (?,?)'); - /** - * get dbxref id. if non-existant, create - * parameters: :dbname, :accession - * returns: dbxref_id - */ - $stm_try_insert_dbxref_id = $db->prepare("SELECT * FROM get_or_insert_dbxref(:dbname, :accession)"); - /** - * get cvterm_id. if non-existant, create - * parameters: name, definition, dbxref_id dbxref_id, dbxref_id - * returns: cvterm_id - */ - $stm_try_insert_cvterm = $db->prepare(<<\t if (count($line) == 2) { - $stm_try_insert_dbxref_id->execute(array( - // parameters: :dbname, :accession - // returns: dbxref_id - self::$db_name, - $line[0] - )); - $dbxref_id = $stm_try_insert_dbxref_id->fetchColumn(); - $dbxrefs[$line[0]] = $dbxref_id; - $stm_try_insert_cvterm->execute(array( - // parameters: name, definition, dbxref_id dbxref_id, dbxref_id - // returns: cvterm_id - $line[0], - $line[1], - $dbxref_id, - $dbxref_id, - $dbxref_id - )); - $cvterms[$line[0]] = $stm_try_insert_cvterm->fetchColumn(); + self::try_insert_dbxref_cvterm($line[0], $line[1]); } else if (count($line) == 5) { //mapping, looks like , , , , "T" if ($line[4] == 'T') { + self::try_insert_dbxref_cvterm($line[0], $line[1]); $stm_get_parentfeature->execute(array( ':object_name' => $line[2], ':organism_id' => DB_ORGANISM_ID, @@ -192,13 +157,14 @@ public static function import($options) { $stm_link_dbxref->execute(array( // parameters: feature_id, cvterm_id $feature_id, - $dbxrefs[$line[0]] + self::$dbxrefs[$line[0]] )); } else //footer, looks like: , , , , "M" if ($line[4] == 'M') { + self::try_insert_dbxref_cvterm($line[0], $line[1]); $val = sprintf("%s\t%s", $line[2], $line[3]); - $cvterm_id = $cvterms[$line[0]]; + $cvterm_id = self::$cvterms[$line[0]]; $stm_try_insert_cvtermprop->execute(array( //cvterm_id, type_id, value, cvterm_id, type_id, cvterm_id, type_id, value $cvterm_id, @@ -236,6 +202,53 @@ public static function CLI_longHelp() { EOF; } + private static function try_insert_dbxref_cvterm($bincode, $desc){ + global $db; + /** + * get dbxref id. if non-existant, create + * parameters: :dbname, :accession + * returns: dbxref_id + */ + $stm_try_insert_dbxref_id = $db->prepare("SELECT * FROM get_or_insert_dbxref(:dbname, :accession)"); + /** + * get cvterm_id. if non-existant, create + * parameters: name, definition, dbxref_id dbxref_id, dbxref_id + * returns: cvterm_id + */ + $stm_try_insert_cvterm = $db->prepare(<<execute(array( + // parameters: :dbname, :accession + // returns: dbxref_id + self::$db_name, + $bincode + )); + $dbxref_id = $stm_try_insert_dbxref_id->fetchColumn(); + self::$dbxrefs[$bincode] = $dbxref_id; + } + $dbxref_id = self::$dbxrefs[$bincode]; + if(!array_key_exists($bincode, self::$cvterms)){ + $stm_try_insert_cvterm->execute(array( + // parameters: name, definition, dbxref_id dbxref_id, dbxref_id + // returns: cvterm_id + $bincode, + $desc, + $dbxref_id, + $dbxref_id, + $dbxref_id + )); + self::$cvterms[$bincode] = $stm_try_insert_cvterm->fetchColumn(); + } + } + } ?> From 4ef2a2aaf2751e8896d3f549f8be76be49e45809 Mon Sep 17 00:00:00 2001 From: Markus Ankenbrand Date: Wed, 1 Mar 2017 11:27:40 +0100 Subject: [PATCH 2/3] Allow singlequote as field enclosure in mapman csv. Fix #45 --- src/cli/import/commands/Importer_Annotations_MapMan.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/import/commands/Importer_Annotations_MapMan.php b/src/cli/import/commands/Importer_Annotations_MapMan.php index 080819f5..d4168170 100644 --- a/src/cli/import/commands/Importer_Annotations_MapMan.php +++ b/src/cli/import/commands/Importer_Annotations_MapMan.php @@ -116,7 +116,7 @@ public static function import($options) { $file = fopen($filename, 'r'); //skip header line fgets($file); - while (($line = fgetcsv($file, 0, "\t")) != false) { + while (($line = fgetcsv($file, 0, "\t", "'")) != false) { //if..elseif..else: check which section we are in // header, looks like \t if (count($line) == 2) { From 3b3b4401b81b8643a19e945a55be84932bc74015 Mon Sep 17 00:00:00 2001 From: Markus Ankenbrand Date: Wed, 1 Mar 2017 17:00:44 +0100 Subject: [PATCH 3/3] Update version to 1.1.2 --- README.md | 3 +++ src/web/wwwroot/index.php | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 548b7d8a..43ea0307 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,9 @@ If you use TBro please cite this publication: [![DOI](https://img.shields.io/bad > Ankenbrand MJ, Weber L, Becker D, Förster F, and Bemm F. "TBro: Visualization and Management of de Novo Transcriptomes." Database 2016 (October 18, 2016): baw146. doi:10.1093/database/baw146. ## Changes +### 1.1.2 <2017-03-01 We> + - Improve MapMan importer + ### 1.1.1 <2016-09-28 Mo> - Custom annotations for unigenes diff --git a/src/web/wwwroot/index.php b/src/web/wwwroot/index.php index cc8649af..e23432e6 100755 --- a/src/web/wwwroot/index.php +++ b/src/web/wwwroot/index.php @@ -31,7 +31,7 @@ require_once('TranscriptDB/webservices/cart/Sync.php'); $smarty->assign('regexCartName', \webservices\cart\Sync::$regexCartName); -$smarty->assign('tbro_version', '1.1.1'); +$smarty->assign('tbro_version', '1.1.2'); $smarty->assign('instance_title', INSTANCE_TITLE); $smarty->assign('logo_url', LOGO_URL); @@ -75,7 +75,7 @@ function requestVal($key, $regexp = "/^.*$/", $defaultvalue = "") { header('Location: ' . preg_replace('/([?&])logout(=[^&]+)?(&|$)/', '$1', $redir_url)); die(); } -//standard LightOpenID login code, see LightOpenID documentation +//standard LightOpenID login code, see LightOpenID documentation try { $openid = new LightOpenID($_SERVER['HTTP_HOST']); if (!$openid->mode) { @@ -155,7 +155,7 @@ function display_feature($organism, $release, $name) { global $db; $stm = $db->prepare(<<