In [1]:
import sys, os
from bl.vl.kb import KnowledgeBase
OME_HOST = os.getenv('OME_HOST', 'localhost')
OME_USER = os.getenv('OME_USER', 'test')
OME_PASSWD = os.getenv('OME_PASSWD', 'test')
CHECK_OME_VERSION = os.getenv('CHECK_OME_VERSION', "True") == "True"
BaseProxy = KnowledgeBase(driver='omero')
class Proxy(BaseProxy):
def get_objects_dict(self, klass):
return dict((o.label, o) for o in super(Proxy, self).get_objects(klass))
kb = Proxy(OME_HOST, OME_USER, OME_PASSWD, check_ome_version=CHECK_OME_VERSION)
def cleanup():
print "# disconnecting the kb"
kb.disconnect()
sys.exitfunc = cleanup
print
print "### KB ENV PRELOADED ###"
print "# connected to %s" % OME_HOST
print "# knowledge base: kb"
print "# extra method: kb.get_objects_dict"
print "########################"
Reload a presaved vcs
In [2]:
vcss = kb.get_objects_dict(kb.VariantCallSupport)
In [3]:
vcss
Out[3]:
In [4]:
vcs = kb.genomics.get_vcs_by_label('human_exom-V1-test+GRCh37.1')
In [5]:
ref_gen = vcs.referenceGenome
In [6]:
ref_gen.label
Out[6]:
In [7]:
ref_gen.nChroms
Out[7]:
In [8]:
nodes = vcs.get_nodes()
for i in range(1, ref_gen.nChroms):
print 'Chrom {} -> {} snps'.format(i, sum(nodes['chrom'] == i))
In [9]:
vcs.get_nodes()[0:10]
Out[9]:
In [10]:
vcs2 = vcs.selection(((1, 762320), (1, 865625)))
In [11]:
vcs3 = vcs.selection(((1, 865545), (1, 865665)))
In [12]:
vcs4 = vcs2.intersection(vcs3)
In [13]:
vcs4.get_nodes()
Out[13]:
In [14]:
vcs5 = vcs2.union(vcs3)
In [15]:
vcs5.get_nodes()
Out[15]:
In [16]:
vcs6 = vcs2.complement(vcs3)
In [17]:
vcs6.get_nodes()
Out[17]:
Note that, unless we do a vcs.save(), the vcs below are all only in the RAM of the client.
In [18]:
len(vcs6)
Out[18]:
In [19]:
vcs6.label
Out[19]:
In [20]:
kb.get_objects_dict(kb.VariantCallSupport)
Out[20]:
In [21]:
vcs6.save()
In [22]:
kb.get_objects_dict(kb.VariantCallSupport)
Out[22]:
In [23]:
kb.delete(vcs6)
In [24]:
kb.get_objects_dict(kb.VariantCallSupport)
Out[24]:
In [25]:
vcs6.get_nodes()
Out[25]:
In [ ]: