Exemple #1
0
    def test_slice_mapping_file(self):
        header, metadata = parse_mapping_file(StringIO(test_mapping))
        table = Table(array([[1, 2], [4, 5]]), ['x', 'y'], ['a', 'c'])

        exp = ["a\t1\t123123", "c\tpoop\tdoesn't matter"]
        obs = slice_mapping_file(table, metadata)
        self.assertEqual(obs, exp)
Exemple #2
0
    def test_slice_mapping_file(self):
        header, metadata = parse_mapping_file(StringIO(test_mapping))
        table = Table(array([[1,2],[4,5]]),
                      ['x','y'],
                      ['a','c'])

        exp = ["a\t1\t123123", "c\tpoop\tdoesn't matter"]
        obs = slice_mapping_file(table, metadata)
        self.assertEqual(obs,exp)
Exemple #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()
__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()