OUTPUT BUFFER:
#!/usr/local/bin/tclsh lappend auto_path /Users/gerald/Personal/Projects/tclws/ package require log package require WS::Client 2.2.7 source PrettyPrint.tcl source refws.tcl proc pdict { d {i 0} {p " "} {s " -> "} } { set errorInfo $::errorInfo set errorCode $::errorCode set fRepExist [expr {0 < [llength\ [info commands tcl::unsupported::representation]]}] while 1 { if { [catch {dict keys $d}] } { if {! [info exists dName] && [uplevel 1 [list info exists $d]]} { set dName $d unset d upvar 1 $dName d continue } return -code error "error: pdict - argument is not a dict" } break } if {[info exists dName]} { puts "dict $dName" } set prefix [string repeat $p $i] set max 0 foreach key [dict keys $d] { if { [string length $key] > $max } { set max [string length $key] } } dict for {key val} ${d} { puts -nonewline "${prefix}[format "%-${max}s" $key]$s" if { $fRepExist && ! [string match "value is a dict*"\ [tcl::unsupported::representation $val]] || ! $fRepExist && [catch {dict keys $val}] } { puts "'${val}'" } else { puts "" pdict $val [expr {$i+1}] $p $s } } set ::errorInfo $errorInfo set ::errorCode $errorCode return "" } proc eFetchPeel {l} { set ::iLevel 0 set ::Lval [list] DoPeeling $l if {$::Lval != {} } { puts " : [join $::Lval]" } unset ::Lval unset ::iLevel return } proc DoPeeling {l} { global iLevel Lval if {$l eq ""} {return} set KeysWithChilds [list "GBSet" "GBSeq" "GBSeq_references" "GBReference" "GBReference_authors" "GBSeq_other-seqids" "GBSeq_feature-table" "GBFeature" "GBFeature_intervals" "GBInterval" "GBFeature_quals" "GBQualifier"] set KeysWithArrays [list GBSeq GBSeqid GBReference GBAuthor GBXref GBFeature GBInterval GBQualifier] set KeysLevels [list 0 GBSeq 1 GBSeqid 1 GBReference 2 GBAuthor 1 GBFeature 2 GBInterval 2 GBQualifier] set gap [string repeat " " $iLevel] set ik 0 while {$ik < [llength $l]} { set k [lindex $l $ik] if {$k in $KeysWithChilds} { lappend ::Lkeys $k set bn "" if {$Lval != {} } { puts " : [join $Lval]" set Lval [list] set bn "\n" } puts "${gap}k = $k" incr ik incr iLevel 2 set Lv [lindex $l $ik] if {$k in $KeysWithArrays} { set ikl [lsearch $KeysLevels $k] set i$k [lindex $KeysLevels ${ikl}-1] foreach v $Lv { DoPeeling $v } } else { DoPeeling $Lv } incr ik incr iLevel -2 continue } if {! [regexp {^GB} $k]} { lappend Lval $k } else { lappend ::Lkeys $k if {$Lval != {} } { puts " : [join $Lval]" set Lval [list] } puts -nonewline "${gap}k = $k" } incr ik } return } proc main_seq {{id ""}} { # WSDL address for fetch service set url "http://www.dasregistry.org/services/das.das_directory?wsdl" set ret [::WS::Client::GetAndParseWsdl "http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/efetch_seq.wsdl"] # list of entries to fetch set Lnm [list xp_570076 xp_002295841 xp_571738] set Lnm "NC_007519" set Lnm [list "YP_386507" xp_0111112321 xp_570076] # query data for a given Id set ft [::WS::Client::DoCall eFetchSequenceService run_eFetch [list db protein id "[join $Lnm ,]"]] # examine output puts "\nExamine output dict" puts "Nbr results : [llength [dict get $ft GBSet GBSeq]]" puts "" puts "[PrettyPrintResult eFetchSequenceService run_eFetch $ft]" puts "" puts "[WS2XML eFetchSequenceService run_eFetch $ft]" exit puts "\nMy way" exit eFetchPeel $ft set Lkeys [lsort -unique $::Lkeys] puts "n keys [llength $Lkeys]" foreach k $Lkeys { if {[set i [string first "_" $k]] != -1} { set k [string range $k $i+1 end] } lappend nk $k } puts "nnet [llength $nk]" return } main_seq exit