From df2b88d0a1463427159fc63f116dbcccb2896167 Mon Sep 17 00:00:00 2001 From: moumou Date: Mon, 18 Nov 2019 13:57:36 +0100 Subject: [PATCH] idmapping_sql OK ! --- src/ordali_services.tcl | 54 +++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/src/ordali_services.tcl b/src/ordali_services.tcl index 438ee03..57b63d2 100755 --- a/src/ordali_services.tcl +++ b/src/ordali_services.tcl @@ -701,6 +701,16 @@ proc IDMappingDir {} { return "/commun/bics/IDMapping/production/" } + +proc ListOfAllIDMappingBanks {} { + if {! [info exists ::ListAllIDMappingBanks]} { + set ::ListAllIDMappingBanks [lsort [LesLignesDuFichier [file join [IDMappingDir] id_dbs.txt]]] + } + + return $::ListAllIDMappingBanks +} + + proc CheckIDMappingInputParam {args} { # This proc is called when doing external call # to IDMapping (setidmapping) @@ -717,7 +727,7 @@ proc CheckIDMappingInputParam {args} { set from [string toupper $from] set to [string toupper $to] - set LidmDBs [lsort [LesLignesDuFichier [file join [IDMappingDir] id_dbs.txt]]] + set LidmDBs [ListOfAllIDMappingBanks] lappend LidmDBs "ACC+ID" ACC ID if {$from ni $LidmDBs || $to ni $LidmDBs} { puts "\nError :\nBad and/or names !" @@ -745,23 +755,8 @@ proc CheckIDMappingInputParam {args} { set Lids [split $Lids " ,;|"] } } - #puts ">$from< >$to< >$Lids< >$taxid<" - - if {$from in {ACC ID ACC+ID} && $to in {ACC ID}} { - if {$from eq "ID"} { - set from UNIPROTKB_ID - } elseif {$to eq "ID"} { - set to UNIPROTKB_ID - } - - return [list $from $to $Lids $taxid] - } - - if {$from in {"GENE_NAME" "GENE_SYNONYM"} && $taxid ne ""} { - return [list $from $to $Lids $taxid] - } else { - return [list $from $to $Lids] - } + + return [list $from $to $Lids $taxid] } @@ -785,13 +780,9 @@ proc DbIDMappingSQL {bank what} { proc IDMapping_sql {from to Lids {taxid ""}} { + lassign [CheckIDMappingInputParam $from $to $Lids $taxid] from to Lids taxid + set Lacc {} - if {$from eq $to} { - puts ">$from> == <$to> !!" - IDMapping_Help - - return - } if {$from ni {ACC ID ACC+ID} && $to ni {ACC ID}} { set jointure 1 @@ -809,7 +800,7 @@ proc IDMapping_sql {from to Lids {taxid ""}} { "ID" - "ACC+ID" { set source acc - if {$to eq "ACC"} { + if {0 && $to eq "ACC"} { set bank "" } else { set bank $to @@ -850,6 +841,14 @@ proc IDMapping_sql {from to Lids {taxid ""}} { return $Lacc } + if {$to eq "ACC"} { + set target acc + } + if {$to eq "ID" || $to eq "ACC"} { + set bank UNIPROTKB_ID + } + + if {! $jointure} { set db [DbIDMappingSQL $bank open] if {$taxid eq ""} { @@ -872,7 +871,7 @@ proc IDMapping_sql {from to Lids {taxid ""}} { set cmd "select db1.id, db2.id from $from as db1, $to as db2 where db1.id in ('[join $Lacc ',']') and db1.acc = db2.acc" } } - #puts "cmd= $cmd\n" + set Lout [$db eval $cmd] $db close @@ -889,9 +888,6 @@ proc IDMapping_sql {from to Lids {taxid ""}} { } } - #lulu - puts "[join $Lres \n]" - exit return $Lres } -- GitLab