Skip to content

Commit

Permalink
Merge pull request #12 from galaxy-genome-annotation/tripal_reflect
Browse files Browse the repository at this point in the history
Fix data loading in Tripal database
  • Loading branch information
abretaud committed Nov 13, 2019
2 parents 1698dc4 + b10fa63 commit 6c460b8
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 24 deletions.
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ jobs:
- sleep 300 # Wait for the container to be ready
script:
- python setup.py nosetests
- stage: test
python: '3.5'
env:
- TRIPAL=1
install:
- pip install -U pip setuptools nose
- python setup.py install
- export CHAKIN_GLOBAL_CONFIG_PATH=`pwd`/test-data/compose/chakin-compose.yml
- sudo service postgresql stop
- cd test-data/compose && docker-compose up -d && cd ../../
- sleep 300 # Wait for the container to be ready
script:
- python setup.py nosetests
- stage: deploy
install: skip
script: echo "Deploying to Pypi"
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ $ chakin feature load_fasta \
## History
- 2.3.1
- Fix data loading in Tripal database
- 2.3.0
- Fix non working --re_parent option in fasta loader
- allow connection using a preformatted url (needed by galaxy tools using pgutil)
Expand Down
17 changes: 9 additions & 8 deletions chado/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,21 @@ class Tripal_analysis_blast(Base):
Base.prepare(self._engine, reflect=True, schema=self.dbschema)
if reflect_tripal_tables and self.dbschema != "public":
Base.prepare(self._engine, reflect=True, schema='public')

# Check for schema name instead of hardcoding?
self.model = Base.classes
self.model.blast_hit_data = Blast_hit_data
self.model.tripal_analysis_blast = Tripal_analysis_blast

# ambiguous relationships to same table
self.model.feature_relationship.subject = relationship("feature", foreign_keys=[self.model.feature_relationship.subject_id], back_populates="subject_in_relationships")
self.model.feature.subject_in_relationships = relationship("feature_relationship", foreign_keys=[self.model.feature_relationship.subject_id])
self.model.feature_relationship.object = relationship("feature", foreign_keys=[self.model.feature_relationship.object_id], back_populates="object_in_relationships")
self.model.feature.object_in_relationships = relationship("feature_relationship", foreign_keys=[self.model.feature_relationship.object_id])

self.model.featureloc.feature = relationship("feature", foreign_keys=[self.model.featureloc.feature_id], back_populates="featureloc_collection")
self.model.feature.featureloc_collection = relationship("featureloc", foreign_keys=[self.model.featureloc.feature_id], back_populates="feature")
self.model.featureloc.srcfeature = relationship("feature", foreign_keys=[self.model.featureloc.srcfeature_id])
self.model.feature_relationship.subject = relationship(self.model.feature, foreign_keys=[self.model.feature_relationship.subject_id], back_populates="subject_in_relationships")
self.model.feature.subject_in_relationships = relationship(self.model.feature_relationship, foreign_keys=[self.model.feature_relationship.subject_id])
self.model.feature_relationship.object = relationship(self.model.feature, foreign_keys=[self.model.feature_relationship.object_id], back_populates="object_in_relationships")
self.model.feature.object_in_relationships = relationship(self.model.feature_relationship, foreign_keys=[self.model.feature_relationship.object_id])

self.model.featureloc.feature = relationship(self.model.feature, foreign_keys=[self.model.featureloc.feature_id], back_populates="featureloc_collection")
self.model.feature.featureloc_collection = relationship(self.model.featureloc, foreign_keys=[self.model.featureloc.feature_id], back_populates="feature")
self.model.featureloc.srcfeature = relationship(self.model.feature, foreign_keys=[self.model.featureloc.srcfeature_id])

def _reflect_tables_subset(self):

Expand Down
2 changes: 1 addition & 1 deletion chado/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def launch_docker_image(self, background=False, no_yeast=False):

cmd += [
'-p', '5432:5432',
'quay.io/galaxy-genome-annotation/chado:1.31-jenkins23-pg9.5'
'quay.io/galaxy-genome-annotation/chado:1.31-jenkins26-pg9.5'
]

subprocess.call(cmd)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="chado",
version='2.3.0',
version='2.3.1',
description="Chado library",
author="Anthony Bretaudeau",
author_email="[email protected]",
Expand Down
13 changes: 13 additions & 0 deletions test-data/compose/chakin-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Chado's chakin: Global Configuration File.
# Each stanza should contain a single chado server to control.
#
# You can set the key __default to the name of a default instance
__default: local

local:
dbhost: "localhost"
dbname: "postgres"
dbuser: "postgres"
dbpass: "postgres"
dbport: "5433"
dbschema: "chado"
20 changes: 20 additions & 0 deletions test-data/compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '2'
services:

tripal:
image: quay.io/galaxy-genome-annotation/tripal
links:
- tripaldb:postgres
environment:
MEMORY_LIMIT: 512M
TRIPAL_GIT_CLONE_MODULES: ""
TRIPAL_DOWNLOAD_MODULES: ""
TRIPAL_ENABLE_MODULES: ""

tripaldb:
image: quay.io/galaxy-genome-annotation/chado:1.31-jenkins26-pg9.5
ports:
- "5433:5432"
environment:
- POSTGRES_PASSWORD=postgres
- INSTALL_CHADO_SCHEMA=0
3 changes: 3 additions & 0 deletions test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@

ci_no_reflect = get_instance('local', no_reflect=True)

ci_reflect_tripal = get_instance('local', reflect_tripal_tables=True)


def setup_package():
global ci
global ci_no_reflect
global ci_reflect_tripal


class ChadoTestCase(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions test/cvterm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_get_id_by_synonym(self):
term = self.ci.get_cvterm_id(name='lives inside of', cv='relationship', allow_synonyms=True)

# The id is hard coded with value from current chado dump
assert term == 432, "Got cvterm id by synonym"
assert term >= 400, "Got cvterm id by synonym"

def test_get_id_by_name_synmultiple(self):

Expand All @@ -34,7 +34,7 @@ def test_get_name(self):
# The id is hard coded with value from current chado dump
term = self.ci.get_cvterm_name(432)

assert term == 'endoparasite_of', "Got cvterm name"
assert 'endoparasite' in term, "Got cvterm name"

@raises(Exception)
def test_get_name_fail(self):
Expand Down
4 changes: 2 additions & 2 deletions test/go_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from nose.tools import raises

from . import ChadoTestCase, ci
from . import ChadoTestCase, ci_reflect_tripal


class GoTest(ChadoTestCase):
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_load_go_bad_query(self):
self.ci.load.go(input="./test-data/go.gaf", analysis_id=an_go['analysis_id'], organism_id=org['organism_id'], query_type='foobar')

def setUp(self):
self.ci = ci
self.ci = ci_reflect_tripal
self.ci.organism.delete_organisms()
self.ci.analysis.delete_analyses()
self.ci.feature.delete_features()
Expand Down
20 changes: 10 additions & 10 deletions test/load_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import ChadoTestCase, ci
from . import ChadoTestCase, ci_reflect_tripal


class LoadTest(ChadoTestCase):
Expand Down Expand Up @@ -122,16 +122,16 @@ def test_get_dbs(self):

def setUp(self):

self.ci = ci
ci.feature.delete_features()
ci.organism.delete_organisms()
ci.analysis.delete_analyses()
self.ci = ci_reflect_tripal
self.ci.feature.delete_features()
self.ci.organism.delete_organisms()
self.ci.analysis.delete_analyses()

ci.session.commit()
self.ci.session.commit()

def tearDown(self):
ci.feature.delete_features()
ci.organism.delete_organisms()
ci.analysis.delete_analyses()
self.ci.feature.delete_features()
self.ci.organism.delete_organisms()
self.ci.analysis.delete_analyses()

ci.session.commit()
self.ci.session.commit()

0 comments on commit 6c460b8

Please sign in to comment.