コード例 #1
0
ファイル: cons_test.py プロジェクト: suliat16/biskit
 def test_build_url_retOMA(self):
     """Tests that build URL inserts the variable portions of the url correcly into the base"""
     self.lyz.sequence = 'MKALIVLGLVLLSVTVQGKVFERCELARTLKRLGMDGYRGISLANWMCLAKWESGYNTRATNYNAGDRSTDYGIFQINSRYWCNDGKTPGAVNACHLSCSALLQDNIADAVACAKRVVRDPQGIRAWVAWRNRCQNRDVRQYVQGCGV'
     self.assertEqual(
         constool.build_url(base_url='https://omabrowser.org',
                            tail='/api/sequence/?query={0}',
                            variation=[self.lyz.sequence]),
         'https://omabrowser.org/api/sequence/?query=MKALIVLGLVLLSVTVQGKVFERCELARTLKRLGMDGYRGISLANWMCLAKWESGYNTRATNYNAGDRSTDYGIFQINSRYWCNDGKTPGAVNACHLSCSALLQDNIADAVACAKRVVRDPQGIRAWVAWRNRCQNRDVRQYVQGCGV'
     )
コード例 #2
0
 def HOG_to_fasta(self):
     """
     Retrieves the fasta file containing the sequences of the proteins in the HOG of the input protein
     """
     url = constool.build_url(base_url=self.OMA_BASE_URL,
                              tail='/oma/hogs/{0}/{1}/fasta/',
                              variation=[self.id, self.hog_level])
     response = requests.get(url)
     if response.status_code == 200:
         self.HOGs = str(response.text)
         return self.HOGs
     else:
         self.save_status = response.status_code
         raise exceptions.RequestException(
             'There was an issue querying the database. Status code {0}'.
             format(self.save_status))
コード例 #3
0
 def update_orthoIDs(self):
     """
     Takes the OMA specific ID of a protein species, and returns a list of the
     canonical IDs of the orthologs of that protein
     Returns:
         A list of strings, the canonical IDS for the orthologs of the protein
     """
     url = constool.build_url(base_url=self.OMA_BASE_URL,
                              tail='/api/protein/{0}/orthologs/',
                              variation=[self.id])
     response = requests.get(url, headers=self.HEADERS)
     if response.status_code == 200:
         self.read_resp_orthoIDs(response)
     else:
         self.save_status = response.status_code
         raise exceptions.RequestException(
             'There was an issue querying the database. Status code {0}'.
             format(self.save_status))
コード例 #4
0
 def ortholog_to_fasta(self):
     """
     Takes an OMA specific ID and returns a fasta string of the orthologs assciated
     with that protein
     Returns:
         A single fasta string containing the orthologs of that protein, as
         dictated by OMA.Note that when the fasta file is parsed,
         the first id is the OMA ID, and the second is the canonical id.
     """
     url = constool.build_url(base_url=self.OMA_BASE_URL,
                              tail='/oma/vps/{0}/fasta/',
                              variation=[self.id])
     response = requests.get(url)
     if response.status_code == 200:
         self.orthologs = str(response.text)
         return self.orthologs
     else:
         self.save_status = response.status_code
         raise exceptions.RequestException(
             'There was an issue querying the database. Status code {0}'.
             format(self.save_status))
コード例 #5
0
 def retrieve_OMAid(self):
     """
     Takes a protein sequence and returns the oma id of the best protein
     match
     Returns:
        A string containing the ID of the best protein match for the entered sequence
     """
     url = constool.build_url(base_url=self.OMA_BASE_URL,
                              tail='/api/sequence/?query={0}',
                              variation=[self.sequence])
     response = requests.get(url, headers=self.HEADERS)
     if response.status_code == 200:
         self.read_resp_protID(response)
     if response.status_code == 504:
         self.save_status = response.status_code
         raise TimeoutError(
             'The database timed out. Could not determine the orthologs of your sequence. Status code {0}'
             .format(self.save_status))
     if response.status_code != 200:
         self.save_status = response.status_code
         raise exceptions.RequestException(
             'There was an issue querying the database. Status code {0}'.
             format(self.save_status))
コード例 #6
0
 def retrieve_HOG_level(self, root=True):
     """
     Retrieve information on the taxonomic levels that the HOG spans through
     Args:
         root(Boolean): if true, return the deepest level of the HOG. If false, return a list
         of the alternative level that the HOG spans through
     Returns: The deepest level relating the HOG, or a list of all the levels
     """
     url = constool.build_url(base_url=self.OMA_BASE_URL,
                              tail='/api/hog/{0}/',
                              variation=[self.id])
     response = requests.get(url, headers=self.HEADERS)
     if response.status_code == 200:
         return self.read_HOGid(response, root)
     if response.status_code == 504:
         self.save_status = response.status_code
         raise TimeoutError(
             'The database timed out. Could not determine the orthologs of your sequence. Status code {0}'
             .format(self.save_status))
     if response.status_code != 200:
         self.save_status = response.status_code
         raise exceptions.RequestException(
             'There was an issue querying the database. Status code {0}'.
             format(self.save_status))