Skip to content

Commit

Permalink
Merge pull request #45 from MoffMade/4.2.9
Browse files Browse the repository at this point in the history
4.2.9 bump, update_organism bugfix
  • Loading branch information
MoffMade authored Sep 4, 2020
2 parents 3cc6145 + bd9b386 commit 637cf34
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ Or with the Arrow client:
History
-------

- 4.2.9
- Bugfix to update_organism when using suppress_output
- 4.2.8
- Added --suppress_output to update_organism
- 4.2.7
Expand Down
12 changes: 7 additions & 5 deletions apollo/organisms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,13 @@ def update_organism(self, organism_id, common_name, directory, blatdb=None, spec
if suppress_output is not None and suppress_output is True:
data['returnAllOrganisms'] = False

response = self.post('updateOrganismInfo', data)[0]

if len(response.keys()) == 0:
return self.show_organism(organism_id)
return response
response = self.post('updateOrganismInfo', data)
if type(response) is not list:
return response
if len(response) > 0:
return [x for x in response if x['commonName'] == common_name][0]
else:
return self.show_organism(common_name)

def get_organisms(self, common_name=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name="apollo",
version='4.2.8',
version='4.2.9',
description="Apollo API library",
long_description=readme,
author="Helena Rasche;Anthony Bretaudeau;Nathan Dunn",
Expand Down
62 changes: 62 additions & 0 deletions test/organism_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ def test_delete_organism_cn(self):
for org in orgs:
assert org['commonName'] != 'temp_org'

def test_delete_organism_suppress(self):

org_info = self.waitOrgCreated('temp_org')

wa.organisms.delete_organism(org_info['id'], suppress_output=True)

self.waitOrgDeleted('temp_org')

orgs = wa.organisms.get_organisms()

for org in orgs:
assert org['commonName'] != 'temp_org'

def test_delete_features(self):

wa.annotations.load_gff3('temp_org', 'test-data/merlin.gff')
Expand Down Expand Up @@ -317,6 +330,31 @@ def test_update_organism_changedseq_noreload(self):
assert seq['name'] == 'Merlin'
assert seq['length'] == 172788

def test_update_organism_suppress(self):

other_org_info = wa.organisms.show_organism('test_organism')

org_info = wa.organisms.show_organism('temp_org')

wa.organisms.update_organism(org_info['id'], 'temp_org', other_org_info['directory'], species='updatedspecies', genus='updatedgenus', blatdb=other_org_info['directory'] + "/seq/genome.2bit", public=False, suppress_output=True)
# Returns useless stuff

time.sleep(3)
org_info = wa.organisms.show_organism('temp_org')

assert org_info['species'] == 'updatedspecies'
assert org_info['genus'] == 'updatedgenus'
assert org_info['blatdb'] == other_org_info['directory'] + "/seq/genome.2bit"
assert not org_info['publicMode']
assert org_info['sequences'] == 1

seqs = wa.organisms.get_sequences(org_info['id'])['sequences']
assert len(seqs) == 1

seq = seqs[0]
assert seq['name'] == 'Merlin'
assert seq['length'] == 172788

def test_add_organism(self):

org_info = wa.organisms.show_organism('test_organism')
Expand All @@ -341,6 +379,30 @@ def test_add_organism(self):
meta_back = json.loads(org_info['metadata'])
assert 'bla' in meta_back and meta_back['bla'] == 'bli'

def test_add_organism_suppress(self):

org_info = wa.organisms.show_organism('test_organism')

meta = {"bla": "bli"}
res = wa.organisms.add_organism('some_new_org', org_info['directory'], species='newspecies', genus='newgenus', blatdb=org_info['directory'] + "/seq/genome.2bit", metadata=meta, suppress_output=True)

assert res['species'] == 'newspecies'
assert res['genus'] == 'newgenus'
assert res['blatdb'] == org_info['directory'] + "/seq/genome.2bit"
meta_back = json.loads(res['metadata'])
assert 'bla' in meta_back and meta_back['bla'] == 'bli'

org_info = self.waitOrgCreated('some_new_org')

wa.organisms.delete_organism(org_info['id'])

assert org_info['species'] == 'newspecies'
assert org_info['genus'] == 'newgenus'
assert org_info['blatdb'] == org_info['directory'] + "/seq/genome.2bit"
assert not org_info['publicMode']
meta_back = json.loads(org_info['metadata'])
assert 'bla' in meta_back and meta_back['bla'] == 'bli'

def setUp(self):
# Make sure the organism is not already there
temp_org_info = wa.organisms.show_organism('temp_org')
Expand Down

0 comments on commit 637cf34

Please sign in to comment.