DESCRIPTIONSnittype for getting information from LocusLink-IDs [
1]. Currently you just download the files from:
ftp://ftp.ncbi.nih.gov/refseq/LocusLink/ . We assume that you download:
ftp://ftp.ncbi.nih.gov/refseq/LocusLink/LL.out_hs.gz and for GeneOntology mappings:
ftp://ftp.ncbi.nih.gov/refseq/LocusLink/loc2go . In the future downloading may be done via http::geturl directly from the package. Candiate for future
biotcl package.
# Author : Dr. Detlef Groth, MPIMG Berlin
# Created By : Dr. Detlef Groth
# Created : Fri Feb 18 13:06:07 2005
# Last Modified : <050222.0622>
#
# Description : snittype for getting informations for LocusLink-IDs.
#
package require snit 0.97
package require oomk
snit::type LocusLinkFile {
option -filename ""
option -mkfile ""
option -gofile ""
variable db
variable dbgo
variable pvLocusLink
# `LocusLinkFile llf -filename LL.out_hs ?-mkfile metakitfile?' --
# constructor for the LocusLinkFile type
# Arguments:
# `-filename filename' the LocusLink file from ftp://ftp.ncbi.nih.gov/refseq/LocusLink/
# `?-mkfile?' the metakit databasefile, defaults to filename.mk
# -----------------------------------------------
constructor {args} {
$self configurelist $args
if {$options(-mkfile) eq ""} {
set options(-mkfile) $options(-filename).mk
}
if {$options(-gofile) eq ""} {
set options(-gofile) [file join [file dirname $options(-filename)] LOC2GO]
}
set db [mkstorage %AUTO% $options(-mkfile)]
if {[file size $options(-mkfile)] < 2} {
$self CreateMkDB
} else {
[$db view locuslink] as pvLocusLink
}
if {[file exists $options(-gofile)] && (![file exists $options(-gofile).mk] || [file size $options(-gofile).mk] < 2)} {
set dbgo [mkstorage %AUTO% $options(-gofile).mk]
$self CreateGoDB
}
};
destructor {
$db close
catch {$dbgo close}
}
# public methods (are lowercase)
# `llf' getInfo -key value ?-mode exact|glob? --
# get info for a certain key might be one of id,symbol, chr or descr), from the LocusLinkDB
# Arguments:
# `key' the property to search for
# Returns:
# list of list where each list contains key/value pairs from the database
# ------------------------------------------------------------
method getInfo {key val args} {
regsub -- {-} $key "" colkey
#puts "colkey $colkey val $val"
set arg(-mode) exact
array set arg $args
[$pvLocusLink select -$arg(-mode) $colkey $val] as pSel
set res [list]
if {[$pSel size] > 0} {
$pSel loop c { lappend res [array get c] }
}
return $res
}
method getGos {key val} {
error "method getGOs is not yet implemented"
}
# private Methods
method CreateGoDB {} {
if [catch {open $options(-gofile) r} infh] {
puts stderr "Cannot open $options(-gofile): $infh"
return 0
} else {
$dbgo layout goinfo {id:I go quality}
[$dbgo view goinfo] as pvGO
set x 0
set prog [Progress %AUTO% -file $options(-gofile)]
puts stderr "Converting $options(-gofile)"
while {[gets $infh line] >= 0} {
set F [split $line \t]
if {[expr $x % 1000] == 0} { $prog progress [tell $infh] }
$pvGO append id [lindex $F 0] go [lindex $F 1] quality [lindex $F 2]
}
close $infh
$dbgo commit
}
}
method CreateMkDB {} {
if [catch {open $options(-filename) r} infh] {
puts stderr "Cannot open $options(-filename): $infh"
return 0
} else {
$db layout locuslink {id symbol chr chrpos descr}
[$db view locuslink] as pvLocusLink
set prog [Progress %AUTO% -file $options(-filename)]
set x 0
while {[gets $infh line] >= 0} {
set F [split $line \t]
if {[expr $x % 100] == 0} { $prog progress [tell $infh] }
$pvLocusLink append id [lindex $F 0] symbol [lindex $F 1] chr [lindex $F 4] \
chrpos [lindex $F 5] descr [lindex $F 6]
}
close $infh
$db commit
#$db close
}
};
}
proc test {} {
source [file join [file dirname [info script]] Progress.tcl]
set file LL.out_hs
set sf [LocusLinkFile %AUTO% -filename /project/goblet/data/LocusLink/$file]
puts [$sf getInfo -id 1]
puts [$sf getInfo -symbol AANAT]
puts [$sf getInfo -chrpos 2q31]
puts [llength [$sf getInfo -chr X]]
puts [$sf getInfo -descr "interleukin*receptor*" -mode glob]
}