예제 #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)
예제 #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)
예제 #3
0
 def test_parse_mapping_file(self):
     exp = ("#SampleIDs\tfoo\tbar", [['a','1\t123123'],
                                     ['b','yy\txxx'],
                                     ['c',"poop\tdoesn't matter"]])
     obs = parse_mapping_file(StringIO(test_mapping))
     self.assertEqual(obs, exp)
예제 #4
0
 def test_parse_mapping_file(self):
     exp = ("#SampleIDs\tfoo\tbar", [['a', '1\t123123'], ['b', 'yy\txxx'],
                                     ['c', "poop\tdoesn't matter"]])
     obs = parse_mapping_file(StringIO(test_mapping))
     self.assertEqual(obs, exp)
예제 #5
0
from sys import argv, exit

__author__ = "Daniel McDonald"
__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))
예제 #6
0
__author__ = "Daniel McDonald"
__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))