Skip to content

Commit

Permalink
protein/orgainism counts in uniprot collection
Browse files Browse the repository at this point in the history
  • Loading branch information
lzy7071 committed Dec 30, 2019
1 parent b331738 commit ee0d161
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
18 changes: 17 additions & 1 deletion datanator_query_python/query/query_protein.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,4 +778,20 @@ def get_equivalent_kegg_with_anchor(self, ko, anchor, max_distance, max_depth=fl
result[level]['documents'].append(equivalent)
checked_ids.append(cur_id)

return result
return result

def get_unique_protein(self):
"""Get number of unique proteins in collection
Return:
(:obj:`int`): number of unique proteins.
"""
return len(self.collection.distinct('uniprot_id', collation=self.collation))

def get_unique_organism(self):
"""Get number of unique organisms in collection.
Return:
(:obj:`int`): number of unique organisms.
"""
return len(self.collection.distinct('ncbi_taxonomy_id'))
12 changes: 10 additions & 2 deletions tests/query/test_query_protein.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ def test_get_info_by_text_abundances(self):
self.assertEqual(result[0]['uniprot_ids'], {'uniprot7': False, 'uniprot0': True})
name = 'Nucleoside diphosphate kinase'
result = self.src_1.get_info_by_text_abundances(name)
print(result[0:9])

def test_get_info_by_taxonid(self):
_id = 6
Expand Down Expand Up @@ -254,4 +253,13 @@ def test_get_kegg_orthology(self):

def test_get_equivalent_kegg_with_anchor(self):
result_0 = self.src_1.get_equivalent_kegg_with_anchor('K03154','Thermus thermophilus HB27', 3, max_depth=2)
self.assertTrue(len(result_0[0]['documents']) > 0)
self.assertTrue(len(result_0[0]['documents']) > 0)

@unittest.skip('passed')
def test_get_unique_protein(self):
result = self.src_1.get_unique_protein()
print(result)

def test_get_unique_organism(self):
result = self.src_1.get_unique_organism()
print(result)

0 comments on commit ee0d161

Please sign in to comment.