Commit 3251bae8 authored by luc.moulinier's avatar luc.moulinier

change open par CheckOpen

parent c459a8f1
......@@ -2541,7 +2541,10 @@ proc SauveLeLog {{fichier ""}} {
}
}
set f [open $fichier w]
set f [CheckOpen $fichier]
if {$f eq ""} {
return
}
global TexteDuLog
if {[info exists TexteDuLog]} {
puts $f [OutputTLog Text $TexteDuLog]
......@@ -5559,14 +5562,12 @@ proc DemandeEtSauveFichier {Extion {exc 0} {FichierParDefaut "Untitled"}} {
update idletasks
if {$file ne ""} {
if {[catch {set o [open $file w]}]} {
FaireLire "Error !\n file is write-protected !"
set file ""
} else {
close $o
file delete $file
set o [CheckOpen $file]
if {$o eq ""} {
return
}
}
return $file
}
......@@ -6808,6 +6809,40 @@ proc ChangeConservation {} {
}
proc ExporteScoreConservation {} {
# Save conservation score as CSV file
global Cons TColScore Defauts
if {$Cons(ConsCou) eq "None"} {
return
}
set ft [SauveConservation]
puts "[join [array names TColScore *$ft*] \n]"
set file "[file rootname $Defauts(Fichier[TypeAli])]_$ft.csv"
#puts "file= $file"
set o [CheckOpen $file]
if {$f eq ""} {
return
}
set Li {}
for {set i 1} {$i < [llength [lindex $TColScore($ft,Data) 0]]} {incr i} {
lappend Li $i
}
puts $o ",[join $Li ,]"
foreach gr $TColScore($ft,Owner) data $TColScore($ft,Data) {
set data [KirsleyData $data]
#puts "\ngrp= $gr [llength $data]"
#plist $data %6.3f
puts $o "$gr,[join $data ,]"
}
close $o
return
}
proc SauveConservation {} {
global TabSF ListeTypesDeFeatures ScoreMeth Cons ConsMeth TColScore LNDG
......@@ -6815,7 +6850,7 @@ proc SauveConservation {} {
return
}
if {[regexp {^Cons\-} $Cons(ConsCou)]} {
return
return $Cons(ConsCou)
}
set ftold [lindex $Cons(ConsCou) 0]
......@@ -6963,7 +6998,7 @@ proc InfosSurOrdali {} {
wm iconname $w "Info"
wm resizable $w 0 0
wm protocol $w WM_DELETE_WINDOW KillParLaCroix
frame $w.f
pack $w.f -side top -expand 1 -fill both
......@@ -8695,7 +8730,7 @@ proc AfficheFrameFeatures {} {
grid columnconfig $FrmBouton 0 -weight 0
grid columnconfig $FrmBouton 1 -weight 1
grid rowconfig $FrmBouton 0 -weight 1
set wmac "$FrmBouton.fimg.limg"
set Wdt [expr {[winfo reqwidth $NomNomSeq] - 10}]
set fmacsim [file join $OrdEtcDir "MACSIM_50px_cut_transparent.gif"]
......
......@@ -1238,7 +1238,10 @@ proc kir {{method ""}} {
SauveConservation
set file "[file rootname [set Defauts(Fichier[TypeAli])]].scores"
set o [open $file w]
set o [CheckOpen $file]
if {$o eq ""} {
return
}
foreach g $LNDG {
set Lv [array names ScoreMeth "Cons-BILD,$g,*"]
puts "\ng= $g [llength $Lv]"
......
......@@ -1088,7 +1088,6 @@ proc AfficheBoutonsConservation {} {
-bg yellow \
-command [list LanceCalculConservation]
set Cons(Show) [set ::Toggle(Scores)]
update
checkbutton $wc.shh \
-text "Show scores " \
-anchor w -justify left \
......@@ -1111,27 +1110,33 @@ proc AfficheBoutonsConservation {} {
-values $Cons(ListeCons)
$wc.call current 0
bind $wc.call <<ComboboxSelected>> [list ChangeConservation]
button $wc.save \
-text " Save " \
-bg green1 \
-command [list SauveConservation]
button $wc.expo \
-text " Export " \
-bg yellow \
-command [list ExporteScoreConservation]
grid $wc.run -row 0 -rowspan 2 -column 0 -sticky nsw -ipadx 5
grid $wc.lal -row 0 -column 1 -sticky nw
grid $wc.call -row 0 -column 2 -sticky new
grid $wc.shh -row 1 -column 1 -columnspan 2 -sticky new -ipadx 5
grid $wc.save -row 0 -column 3 -sticky ew -padx 10
grid $wc.expo -row 1 -column 3 -sticky ew -padx 10
grid rowconfig $wc all -weight 1
# frame save/return
set wb "$ws.sds"
frame $wb
grid $wb -row 0 -column 2 -sticky nse -padx 2 -pady 2
button $wb.save \
-text " Save " \
-bg green1 \
-command [list SauveConservation]
button $wb.dis \
-text "Return" \
-background green1 \
-command [list QuitteModeConservation $ws]
grid $wb.save -row 0 -column 0 -sticky new
grid $wb.dis -row 1 -column 0 -sticky new
#grid $wb.save -row 0 -column 0 -sticky new
grid $wb.dis -row 0 -column 0 -sticky new
update idletasks
trace add variable Cons(PDB) write PrendPDBDansPilier
......
#
# ordali_outils.tcl
#
proc CheckOpen {f} {
if {[catch {set o [open $f w]}]} {
if {[ModeI]} {
FaireLire "Warning !\n The file >$f< can not be written ! Check permissions."
}
set o ""
}
return $o
}
proc RepresentantDeTaxId {t} {
global TDesTaxId TDesOrganismes LNOrdali
......
#
# ordali_sequence.tcl
#
......@@ -11,7 +13,7 @@ proc OuvrirFichierAlignementDansOrdali {{type "Unk"} {Fichier ""}} {
return
}
if {[string tolower $type] eq "macsim"} {set type "XML"}
if {[string tolow]er $type] eq "macsim"} {set type "XML"}
set tyfi $type
if {$type eq "Unk"} {set tyfi "all"}
......@@ -160,7 +162,7 @@ proc DecortiqueUnNEXUS {file aNom aSeq} {
foreach l [lrange $Lignes 1 end] {
set l [string trim $l]
if {[regexp -nocase {^begin} $l]} {
set what [lindex [split $l " "] 1]
set hat [lindex [split $l " "] 1]
}
}
......@@ -510,11 +512,8 @@ proc CreeLeMSF {{outfile ""} {LNoms {}} {LSeqs {}}} {
lappend Llg "\n\n"
if {$outfile ne "OnRetourne"} {
if {[catch {set f [open $outfile w]}]} {
if {[ModeI]} {
FaireLire "Warning !\nFile $outfile can not be open !"
}
set f [CheckOpen $outfile]
if {$f eq ""} {
return
}
puts $f [join $Llg \n]
......@@ -558,7 +557,7 @@ proc CreeLAlignementDeLaFenetre {format {outfile ""}} {
}
set ftmp [file join $OrdTmpDir "[pid]_tfatmptfatmp.tfa"]
set f [open $ftmp w]
set f [CheckOpen $ftmp]
set LongueurTotale [expr {$xx-$xm}]
foreach Nm $noms Sq $seqs {
puts $f ">$Nm"
......@@ -661,12 +660,9 @@ proc CreeLeAln {{FilOut ""}} {
}
if {$FilOut eq ""} {return}
if {[catch {set f [open $FilOut w]}]} {
if {[ModeI]} {
FaireLire "Warning !\nFile $outfile can not be open !"
}
return
set f [CheckOpen $FilOut]
if {$f eq ""} {
return
}
puts $f "CLUSTAL W : Created by Ordalie [DonneDateEtHeure]"
puts $f ""
......@@ -711,13 +707,11 @@ proc EcritLeTfa {FilOut LesNoms LesSequences} {
}
if {$FilOut eq ""} {return}
if {[catch {set f [open $FilOut w]}]} {
if {[ModeI]} {
FaireLire "Warning !\nFile $fileOut can not be open !"
}
set f [CheckOpen $FilOut]
if {$f eq ""} {
return
}
foreach Nm $LesNoms s $LesSequences {
if {[string trim $Nm] eq ""} {continue}
puts $f ">$Nm"
......
......@@ -668,7 +668,7 @@ proc IDMapping_help {{args ""}} {
if {$args eq ""} {
puts "Usage : idmapping <from> <to> <ids list>"
puts ""
puts " <from> should be one of ACC ID ACC+DI"
puts " <from> should be one of ACC ID ACC+ID"
puts " OR "
puts " <to> should be one of ACC ID"
puts ""
......@@ -718,7 +718,7 @@ proc CheckIDMappingInputParam {args} {
set to [string toupper $to]
set LidmDBs [lsort [LesLignesDuFichier [file join [IDMappingDir] id_dbs.txt]]]
lappend LidmDBs "ACC+ID" ACC
lappend LidmDBs "ACC+ID" ACC ID
if {$from ni $LidmDBs || $to ni $LidmDBs} {
puts "\nError :\nBad <FROM_db> and/or <TO_db> names !"
IDMapping_help
......@@ -786,12 +786,19 @@ proc DbIDMappingSQL {bank what} {
proc IDMapping_sql {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
} else {
set jointure 0
}
switch $from {
"ACC" {
set source acc
......@@ -802,7 +809,11 @@ proc IDMapping_sql {from to Lids {taxid ""}} {
"ID" -
"ACC+ID" {
set source acc
set bank $to
if {$to eq "ACC"} {
set bank ""
} else {
set bank $to
}
set target id
# get everything as an ACC
......@@ -833,7 +844,12 @@ proc IDMapping_sql {from to Lids {taxid ""}} {
set Lacc $Lids
}
}
# idmapping inside UniProt itself
if {$bank eq ""} {
return $Lacc
}
if {! $jointure} {
set db [DbIDMappingSQL $bank open]
if {$taxid eq ""} {
......@@ -1190,9 +1206,9 @@ proc InfosFromUniProt {Lids {Lsqn ""}} {
}
unset -nocomplain TInf
Espionne $em
#Espionne $em
array set TInf [DecortiqueLesLignesEMBL $em ID AC DE GN OS OC OX Seq LaDETotal GNTotal]
Espionne [string range $em 0 11]=$AC
#Espionne [string range $em 0 11]=$AC
# access: take all of them, if we have an obsolete one
set AC [string map {";" ""} [join $TInf(AC)]]
regsub -all { +} [string trim $AC] " " AC
......
#
# ordali_setup.tcl
#
......@@ -957,7 +958,8 @@ proc SauveOrdalieDefauts {{fout ""}} {
}
}
if {[catch {set foo [open $fout w]} Msg]} {
set foo [CheckOpen $fout]
if {$foo eq ""} {
return
}
foreach e [set Defauts(UserDef)] {
......
#
# ordali_tree.tcl
#
......@@ -366,7 +367,10 @@ proc NettoieArbre {a} {
}
set a [string map [list " " ""] $a]
set o [open treenet w]
set o [CheckOpen treenet]
if {$o eq ""} {
return
}
puts $o $a
close $o
......@@ -554,7 +558,10 @@ proc SaveTree {AId {file ""}} {
}
if {$file eq ""} {return}
set fo [open $file w]
set fo [CheckOpen $file]
if {$fo eq ""} {
return
}
puts $fo $::Abr($AId,TextePH)
close $fo
......@@ -3601,7 +3608,10 @@ proc EcritUnArbre {AId {fout ""}} {
EcritUnNoeud $AId root
append Abr($AId,OutPH) ";"
set o [open $fout w]
set o [CheckOpen $fout]
if {$o eq ""} {
return
}
puts $o $Abr($AId,OutPH)
close $o
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment