Esempio n. 1
0
def get_alpha(r4s):
    """
    Get the alpha parameter of the conservation scores, as defined by rate4site
    Args:
        r4s (file): The absolute file path to the alignment file
    Returns:
        The alpha parameter of the conservation score.
    """
    try:
        if os.path.isfile(r4s):
            with open(r4s, 'r') as f:
                contents = f.read()
            splitted = contents.split(os.linesep)
            for s in splitted:
                if re.search('alpha parameter', s):
                    parameter = constool.get_num(s)
                    return parameter[0]
            raise Rate4SiteError('File format is not supported')
        else:
            raise FileNotFoundError
    except IndexError:
        raise Rate4SiteError('File format is not supported')
    finally:
        warnings.warn("This method is especially susceptible to changes in the format of \
        the output file", Warning)
Esempio n. 2
0
 def test_get_num_negative(self):
     """Tests that get_num can retrieve negative and positive numbers from within a string"""
     digit = constool.get_num(
         "Hello, how are all 1234.56 and -42 of you today")
     self.assertEqual(digit, [1234.56, -42])
Esempio n. 3
0
 def test_get_num_none(self):
     """Tests that a string containing no digits returns no digits"""
     digit = constool.get_num("Oh, there are none of you today")
     self.assertEqual(digit, [])
Esempio n. 4
0
 def test_get_num_multi(self):
     """Tests that get_num can retrieve multiple floats and integers from a string """
     digit = constool.get_num(
         "Hello, how are all 1234.56 and 42 of you today")
     self.assertEqual(digit, [1234.56, 42])
Esempio n. 5
0
 def test_get_num_good(self):
     """Tests that get num can retrieve a single float from a string"""
     digit = constool.get_num("Hello, how are all 1234.56 of you today")
     self.assertEqual(digit[0], 1234.56)