Exemplo n.º 1
0
 def test_verify_subset(self):
     metadata = [('a','other stuff\tfoo'), ('b', 'asdasdasd'), 
                 ('c','123123123')]
     table = table_factory(array([[1,2,3],[4,5,6]]), ['a','b','c'], ['x','y'])
     self.assertTrue(verify_subset(table, metadata))
     table = table_factory(array([[1,2],[3,4]]), ['a','b'], ['x','y'])
     self.assertTrue(verify_subset(table, metadata))
     table = table_factory(array([[1,2,3],[4,5,6]]), ['a','b','x'], ['x','y'])
     self.assertFalse(verify_subset(table, metadata))
Exemplo n.º 2
0
 def test_verify_subset(self):
     metadata = [('a','other stuff\tfoo'), ('b', 'asdasdasd'), 
                 ('c','123123123')]
     table = table_factory(array([[1,2,3],[4,5,6]]), ['a','b','c'], ['x','y'])
     self.assertTrue(verify_subset(table, metadata))
     table = table_factory(array([[1,2],[3,4]]), ['a','b'], ['x','y'])
     self.assertTrue(verify_subset(table, metadata))
     table = table_factory(array([[1,2,3],[4,5,6]]), ['a','b','x'], ['x','y'])
     self.assertFalse(verify_subset(table, metadata))
Exemplo n.º 3
0
__copyright__ = "Copyright 2013, The American Gut Project"
__credits__ = ["Daniel McDonald"]
__license__ = "BSD"
__version__ = "unversioned"
__maintainer__ = "Daniel McDonald"
__email__ = "*****@*****.**"

if __name__ == '__main__':
    if len(argv) != 4:
        print "usage: python %s mappingfile table output" % argv[0]
        exit(1)

    header, mapping_file = parse_mapping_file(open(argv[1]))

    table = load_table(argv[2])

    if not verify_subset(table, mapping_file):
        print "****"
        print set([i[0] for i in mapping_file]) - set(table.ids())
        print set(table.ids()) - set([i[0] for i in mapping_file])
        raise ValueError("The table is not a subset of the mapping file!")

    sliced = slice_mapping_file(table, mapping_file)

    f = open(argv[3], 'w')
    f.write(header)
    f.write('\n')
    f.write('\n'.join(sliced))
    f.write('\n')
    f.close()
Exemplo n.º 4
0
__credits__ = ["Daniel McDonald"]
__license__ = "BSD"
__version__ = "unversioned"
__maintainer__ = "Daniel McDonald"
__email__ = "*****@*****.**"


if __name__ == "__main__":
    if len(argv) != 4:
        print "usage: python %s mappingfile table output" % argv[0]
        exit(1)

    header, mapping_file = parse_mapping_file(open(argv[1]))

    table = load_table(argv[2])

    if not verify_subset(table, mapping_file):
        print "****"
        print set([i[0] for i in mapping_file]) - set(table.ids())
        print set(table.ids()) - set([i[0] for i in mapping_file])
        raise ValueError("The table is not a subset of the mapping file!")

    sliced = slice_mapping_file(table, mapping_file)

    f = open(argv[3], "w")
    f.write(header)
    f.write("\n")
    f.write("\n".join(sliced))
    f.write("\n")
    f.close()