def testClusterNamingWithBootstraps(self): tree = TreeNode.read( StringIO( "((F:20, ((A:11, B:12):10, (H:8, D:9):3):20)'0.7:G':30)root;")) clusters = Tree2Tax().named_clusters(tree, 40) self.assertSameClusters([['F'], _('A B D H')], clusters) assert_equals(_('G.2 G.1'), [c.name() for c in clusters])
def testNaming(self): tree = TreeNode.read( StringIO('((F:20, ((A:11, B:12):10, (H:8, D:9):3):20)G:30)root;')) clusters = Tree2Tax().named_clusters_for_several_thresholds( tree, [40, 25]) self.assertSameClusterSets( [[25, [['F'], _('A B'), _('D H')]], [40, [['F'], _('A B D H')]]], clusters) assert_equals(_('G.3 G.1 G.2'), [c.name() for c in clusters[0].clusters]) assert_equals(_('G.2 G.1'), [c.name() for c in clusters[1].clusters])
def testTipToCluster(self): tree = TreeNode.read(StringIO('((F:20, ((A:11, B:12):10, (H:8, D:9):3):20)G:30)root;')) clusters = Tree2Tax().named_clusters_for_several_thresholds(tree, [40, 25]) self.assertSameClusterSets([[25,[['F'], _('A B'), _('D H')]], [40,[['F'], _('A B D H')]]], clusters) assert_equals(_('G.3 G.1 G.2'), [c.name() for c in clusters[0].clusters]) assert_equals(_('G.2 G.1'), [c.name() for c in clusters[1].clusters]) tip = tree.find('F') assert_equals('G.3', clusters[0].tip_to_cluster(tip).name()) assert_equals('G.2', clusters[1].tip_to_cluster(tip).name()) tip = tree.find('D') assert_equals('G.2', clusters[0].tip_to_cluster(tip).name()) assert_equals('G.1', clusters[1].tip_to_cluster(tip).name())
def welcome(name): _("Hello"+"There") _(17) _("Hi, {0}".format(name)) # pylint: disable=translation-of-non-string _(name) # pylint: enable=translation-of-non-string gettext("hi, %s" % name)
def testOppositeSorting(self): tree = TreeNode.read(StringIO('((A:0.11, B:0.12)C:0.1, D:0.2)root;')) clusters = Tree2Tax().named_clusters_for_several_thresholds( tree, [0.05, 0.25]) self.assertSameClusterSets( [[0.05, [['A'], ['B'], ['D']]], [0.25, [['A', 'B'], ['D']]]], clusters) assert_equals(_('C.1 C.2 Root'), [c.name() for c in clusters[0].clusters])
def testNamingWithBootstraps(self): tree = TreeNode.read(StringIO('((A:0.11, B:0.12)0.091:0.1, D:0.2)root;')) clusters = Tree2Tax().named_clusters(tree, 0.05) self.assertSameClusters([['A'],['B'],['D']], clusters) assert_equals(_('Root.1 Root.2 Root.3'), [c.name() for c in clusters])
def testClusterNamingOnTwoInternalNodesReverseOrder(self): tree = TreeNode.read(StringIO('((F:20, ((A:11, B:12):10, (H:8, D:9):3):20)G:30)root;')) clusters = Tree2Tax().named_clusters(tree, 40) self.assertSameClusters([['F'], _('A B D H')], clusters) assert_equals(_('G.2 G.1'), [c.name() for c in clusters])
def testClusterIntoThree(self): tree = TreeNode.read(StringIO('((((A:11, B:12)C:10, (H:8, D:9)I:3)E:20, F:20)G:30)root;')) clusters = Tree2Tax().named_clusters(tree, 25) self.assertSameClusters([_('A B'), _('D H'), ['F']], clusters)
def testClusterOnTwoInternalNodes(self): tree = TreeNode.read(StringIO('((((A:11, B:12)C:10, (H:8, D:9)I:3)E:20, F:20)G:30)root;')) clusters = Tree2Tax().named_clusters(tree, 40) self.assertSameClusters([_('A B D H'), ['F']], clusters)
def testNoClusering(self): tree = TreeNode.read(StringIO('((A:0.11, B:0.12)C:0.1, D:0.2)root;')) clusters = Tree2Tax().named_clusters(tree, 0.05) self.assertSameClusters([['A'],['B'],['D']], clusters) assert_equals(_('C.1 C.2 Root'), [c.name() for c in clusters])
"""These are all good uses of _()""" from string import lower as _ _("Hello") _( """ This is a long string. """ ) _("This " "is " "also " "long.")
def testClusterNamingWithBootstraps(self): tree = TreeNode.read(StringIO("((F:20, ((A:11, B:12):10, (H:8, D:9):3):20)'0.7:G':30)root;")) clusters = Tree2Tax().named_clusters(tree, 40) self.assertSameClusters([['F'], _('A B D H')], clusters) assert_equals(_('G.2 G.1'), [c.name() for c in clusters])
def test_match_alignment_and_tree_sequence_ids_align_not_tree(self): self.assertRaises(Exception, self.match, u'(a,(b,c));',_('a b c d'))
def testNamingWithBootstraps(self): tree = TreeNode.read( StringIO('((A:0.11, B:0.12)0.091:0.1, D:0.2)root;')) clusters = Tree2Tax().named_clusters(tree, 0.05) self.assertSameClusters([['A'], ['B'], ['D']], clusters) assert_equals(_('Root.1 Root.2 Root.3'), [c.name() for c in clusters])
def testClusterNamingOnTwoInternalNodesReverseOrder(self): tree = TreeNode.read( StringIO('((F:20, ((A:11, B:12):10, (H:8, D:9):3):20)G:30)root;')) clusters = Tree2Tax().named_clusters(tree, 40) self.assertSameClusters([['F'], _('A B D H')], clusters) assert_equals(_('G.2 G.1'), [c.name() for c in clusters])
def testClusterIntoThree(self): tree = TreeNode.read( StringIO( '((((A:11, B:12)C:10, (H:8, D:9)I:3)E:20, F:20)G:30)root;')) clusters = Tree2Tax().named_clusters(tree, 25) self.assertSameClusters([_('A B'), _('D H'), ['F']], clusters)
def testClusterOnTwoInternalNodes(self): tree = TreeNode.read( StringIO( '((((A:11, B:12)C:10, (H:8, D:9)I:3)E:20, F:20)G:30)root;')) clusters = Tree2Tax().named_clusters(tree, 40) self.assertSameClusters([_('A B D H'), ['F']], clusters)
def testNoClusering(self): tree = TreeNode.read(StringIO('((A:0.11, B:0.12)C:0.1, D:0.2)root;')) clusters = Tree2Tax().named_clusters(tree, 0.05) self.assertSameClusters([['A'], ['B'], ['D']], clusters) assert_equals(_('C.1 C.2 Root'), [c.name() for c in clusters])
def test_match_alignment_and_tree_sequence_ids(self): self.match(u'(a,(b,c));',_('a b c'))
parser.add_argument('-i', '--input_taxonomy', help='output the taxonomy to this file', required=True) parser.add_argument('-o', '--output_taxonomy', help='output the taxonomy to this file', required=True) parser.add_argument('--debug', help='output debug information', action="store_true") args = parser.parse_args() if args.debug: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.INFO) # read in taxonomy file, keeping hashes of taxonomy => [[parent,count],..] and just an array of the taxonomies taxonomy = [] expected_taxonomy_levels = 7 rank_bits = _('k p c o f g s') child_to_parent_counts = [None] * (expected_taxonomy_levels-1) for i in range(expected_taxonomy_levels-1): child_to_parent_counts[i] = {} regex = re.compile(r'^.__') logging.info("Reading in taxonomy file..") with open(args.input_taxonomy) as f: for input_line1 in f: input_line = input_line1.rstrip() # split first by tab, then by '; ' splits = input_line.split("\t") if len(splits) != 2:
def test_match_alignment_and_tree_sequence_ids_underscores(self): self.match(u'(\'a_2\',(b,c));',_('a_2 b c'))
def testOppositeSorting(self): tree = TreeNode.read(StringIO('((A:0.11, B:0.12)C:0.1, D:0.2)root;')) clusters = Tree2Tax().named_clusters_for_several_thresholds(tree, [0.05, 0.25]) self.assertSameClusterSets([[0.05,[['A'],['B'],['D']]], [0.25,[['A','B'],['D']]]], clusters) assert_equals(_('C.1 C.2 Root'), [c.name() for c in clusters[0].clusters])