Esempio n. 1
0
 def test_host_comparison(self):
     """instances with same host, account, database, port are equal"""
     h1 = HostAccount("ensembldb.ensembl.org", "anonymous", "", port=5306)
     h2 = HostAccount("ensembldb.ensembl.org", "anonymous", "", port=5306)
     self.assertNotEqual(id(h1), id(h2))
     self.assertEqual(h1, h2)
     # hashes are also equal
     self.assertEqual(hash(h1), hash(h2))
     h3 = HostAccount("ensembldb.ensembl.org", "anonymous", "", port=5300)
     self.assertNotEqual(h1, h3)
     self.assertNotEqual(hash(h1), hash(h3))
Esempio n. 2
0
from cogent.db.ensembl.database import Database

__author__ = "Gavin Huttley, Hua Ying"
__copyright__ = "Copyright 2007-2009, The Cogent Project"
__credits__ = ["Gavin Huttley", "hua Ying"]
__license__ = "GPL"
__version__ = "1.4.1"
__maintainer__ = "Gavin Huttley"
__email__ = "*****@*****.**"
__status__ = "alpha"

Release = 56

if 'ENSEMBL_ACCOUNT' in os.environ:
    username, password = os.environ['ENSEMBL_ACCOUNT'].split()
    account = HostAccount('127.0.0.1', username, password)
else:
    account = get_ensembl_account(release=Release)


class TestDatabase(TestCase):
    def test_connect(self):
        human = Database(account=account,
                         release=Release,
                         species='human',
                         db_type='core')
        gene = human.getTable('gene')

    def test_get_distinct(self):
        """should return list of strings"""
        db = Database(account=account,
Esempio n. 3
0
__credits__ = ["Gavin Huttley", "hua Ying"]
__license__ = "GPL"
__version__ = "1.5.3-dev"
__maintainer__ = "Gavin Huttley"
__email__ = "*****@*****.**"
__status__ = "alpha"

Release = 76

if 'ENSEMBL_ACCOUNT' in os.environ:
    args = os.environ['ENSEMBL_ACCOUNT'].split()
    host, username, password = args[0:3]
    kwargs = {}
    if len(args) > 3:
        kwargs['port'] = int(args[3])
    account = HostAccount(host, username, password, **kwargs)
else:
    account = get_ensembl_account(release=Release)


class TestEnsemblDbName(TestCase):
    def test_cmp_name(self):
        """should validly compare names by attributes"""
        n1 = EnsemblDbName('homo_sapiens_core_46_36h')
        n2 = EnsemblDbName('homo_sapiens_core_46_36h')
        self.assertEqual(n1, n2)

    def test_name_without_build(self):
        """should correctly handle a db name without a build"""
        n = EnsemblDbName("pongo_pygmaeus_core_49_1")
        self.assertEqual(n.Prefix, "pongo_pygmaeus")
Esempio n. 4
0
from cogent.db.ensembl.host import HostAccount, get_ensembl_account
from cogent.db.ensembl.compara import Compara, Genome
from cogent.util.unit_test import TestCase, main

__author__ = "Jason Merkin"
__copyright__ = "Copyright 2007-2012, The Cogent Project"
__credits__ = ["Gavin Huttley", "Hua Ying"]
__license__ = "GPL"
__version__ = "1.5.3-dev"
__maintainer__ = "Gavin Huttley"
__email__ = "*****@*****.**"
__status__ = "alpha"

Release = 12
account = HostAccount('mysql.ebi.ac.uk','anonymous', '', port=4157)

class MZ_ComparaTestBase(TestCase):
    comp = Compara(['D.grimshawi', 'D.melanogaster'], Release=Release,
                    account=account, division='metazoa')

class MZ_TestCompara(MZ_ComparaTestBase):
    def test_query_genome(self):
        """compara should attach valid genome attributes by common name"""
        brca2 = self.comp.Dmelanogaster.getGeneByStableId("FBgn0050169")
        self.assertEquals(brca2.Symbol.lower(), 'brca2')
    
    def test_get_related_genes(self):
        """should correctly return the related gene regions from each genome"""
        # using sc35, a splicing factor
        sc35 = self.comp.Dmelanogaster.getGeneByStableId("FBgn0040286")
        Orthologs = self.comp.getRelatedGenes(gene_region=sc35,