Example #1
0
 def _clean_accession(self, accession_string):
     if accession_string.startswith(">"):
         accession_string = accession_string[1:]
     accession_string = accession_string.strip()
     result = None
     if "|" in accession_string:
         try:
             fields = fasta.default_parser(accession_string)
             result = fields.accession
         except fasta.UnparsableDeflineError:
             result = accession_string
     else:
         result = accession_string
     return result
Example #2
0
 def name_getter(x):
     header = fasta.default_parser(x)
     try:
         return header.accession
     except Exception:
         return header[0]
 def test_accession_alone(self):
     header = "P16066"
     result = fasta.default_parser(header)
     self.assertRaises(AttributeError, lambda: result.accession)
     self.assertEqual(result[0], "P16066")
 def test_partial_uniprot(self):
     header = "P16066|ANPRA_HUMAN"
     result = fasta.default_parser(header)
     self.assertEqual(result.accession, "P16066")
 def test_without_prefix(self):
     header = "sp|P16066|ANPRA_HUMAN Atrial natriuretic peptide receptor 1"
     result = fasta.default_parser(header)
     self.assertEqual(result.accession, "P16066")