Beispiel #1
0
 def test_distance_floats(self):
     """ distance calculations on floats should throw no errors"""
     # testing floats
     exp_out = "\tPC.481\tPC.607\tPC.634\tPC.635\tPC.593\tPC.636\tPC.355\tPC.354\tPC.356\nPC.481\t0.0\t0.2\t0.3\t0.4\t0.1\t0.5\t0.2\t0.3\t0.1\nPC.607\t0.2\t0.0\t0.1\t0.2\t0.1\t0.3\t0.4\t0.5\t0.3\nPC.634\t0.3\t0.1\t0.0\t0.1\t0.2\t0.2\t0.5\t0.6\t0.4\nPC.635\t0.4\t0.2\t0.1\t0.0\t0.3\t0.1\t0.6\t0.7\t0.5\nPC.593\t0.1\t0.1\t0.2\t0.3\t0.0\t0.4\t0.3\t0.4\t0.2\nPC.636\t0.5\t0.3\t0.2\t0.1\t0.4\t0.0\t0.7\t0.8\t0.6\nPC.355\t0.2\t0.4\t0.5\t0.6\t0.3\t0.7\t0.0\t0.1\t0.1\nPC.354\t0.3\t0.5\t0.6\t0.7\t0.4\t0.8\t0.1\t0.0\t0.2\nPC.356\t0.1\t0.3\t0.4\t0.5\t0.2\t0.6\t0.1\t0.2\t0.0"
     res_out = distance_matrix(StringIO.StringIO(self.fasting_map),
                               "Float_Col")
     self.assertEqual(exp_out, res_out)
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    if opts.output_dir.endswith('.txt'):
        stderr.write('output must be a directory, files will be named'+\
          ' automatically.  And we refuse to make .txt directories\n')
        exit(1)

    try:
        os.makedirs(opts.output_dir)
    except OSError:
        pass  # hopefully dir already exists

    dtx_txt = distance_matrix(open(opts.input_path, 'U'), opts.column)

    outfilepath = os.path.join(opts.output_dir, opts.column + '.txt')
    f = open(outfilepath, 'w')
    f.write(dtx_txt)
    f.close()
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)
  
    if opts.output_dir.endswith('.txt'):
        stderr.write('output must be a directory, files will be named'+\
          ' automatically.  And we refuse to make .txt directories\n')
        exit(1)
    
    try: 
        os.makedirs(opts.output_dir)
    except OSError:
        pass # hopefully dir already exists
    
    dtx_txt = distance_matrix(open(opts.input_path,'U'), opts.column)
    
    outfilepath = os.path.join(opts.output_dir, opts.column + '.txt')
    f = open(outfilepath,'w')
    f.write(dtx_txt)
    f.close()
 def test_distance_floats(self):
     """ distance calculations on floats should throw no errors"""
     # testing floats
     exp_out = "\tPC.481\tPC.607\tPC.634\tPC.635\tPC.593\tPC.636\tPC.355\tPC.354\tPC.356\nPC.481\t0.0\t0.2\t0.3\t0.4\t0.1\t0.5\t0.2\t0.3\t0.1\nPC.607\t0.2\t0.0\t0.1\t0.2\t0.1\t0.3\t0.4\t0.5\t0.3\nPC.634\t0.3\t0.1\t0.0\t0.1\t0.2\t0.2\t0.5\t0.6\t0.4\nPC.635\t0.4\t0.2\t0.1\t0.0\t0.3\t0.1\t0.6\t0.7\t0.5\nPC.593\t0.1\t0.1\t0.2\t0.3\t0.0\t0.4\t0.3\t0.4\t0.2\nPC.636\t0.5\t0.3\t0.2\t0.1\t0.4\t0.0\t0.7\t0.8\t0.6\nPC.355\t0.2\t0.4\t0.5\t0.6\t0.3\t0.7\t0.0\t0.1\t0.1\nPC.354\t0.3\t0.5\t0.6\t0.7\t0.4\t0.8\t0.1\t0.0\t0.2\nPC.356\t0.1\t0.3\t0.4\t0.5\t0.2\t0.6\t0.1\t0.2\t0.0"
     res_out = distance_matrix(StringIO.StringIO(self.fasting_map), "Float_Col")
     self.assertEqual(exp_out, res_out)
 def test_distance_int(self):
     """ distance calculations on ints should throw no errors"""
     exp_out = "\tPC.481\tPC.607\tPC.634\tPC.635\tPC.593\tPC.636\tPC.355\tPC.354\tPC.356\nPC.481\t0.0\t798.0\t9802.0\t9802.0\t896.0\t9802.0\t9096.0\t9096.0\t9188.0\nPC.607\t798.0\t0.0\t9004.0\t9004.0\t98.0\t9004.0\t9894.0\t9894.0\t9986.0\nPC.634\t9802.0\t9004.0\t0.0\t0.0\t8906.0\t0.0\t18898.0\t18898.0\t18990.0\nPC.635\t9802.0\t9004.0\t0.0\t0.0\t8906.0\t0.0\t18898.0\t18898.0\t18990.0\nPC.593\t896.0\t98.0\t8906.0\t8906.0\t0.0\t8906.0\t9992.0\t9992.0\t10084.0\nPC.636\t9802.0\t9004.0\t0.0\t0.0\t8906.0\t0.0\t18898.0\t18898.0\t18990.0\nPC.355\t9096.0\t9894.0\t18898.0\t18898.0\t9992.0\t18898.0\t0.0\t0.0\t92.0\nPC.354\t9096.0\t9894.0\t18898.0\t18898.0\t9992.0\t18898.0\t0.0\t0.0\t92.0\nPC.356\t9188.0\t9986.0\t18990.0\t18990.0\t10084.0\t18990.0\t92.0\t92.0\t0.0"
     res_out = distance_matrix(StringIO.StringIO(self.fasting_map), "DOB")
     self.assertEqual(exp_out, res_out)
Beispiel #6
0
 def test_distance_int(self):
     """ distance calculations on ints should throw no errors"""
     exp_out = "\tPC.481\tPC.607\tPC.634\tPC.635\tPC.593\tPC.636\tPC.355\tPC.354\tPC.356\nPC.481\t0.0\t798.0\t9802.0\t9802.0\t896.0\t9802.0\t9096.0\t9096.0\t9188.0\nPC.607\t798.0\t0.0\t9004.0\t9004.0\t98.0\t9004.0\t9894.0\t9894.0\t9986.0\nPC.634\t9802.0\t9004.0\t0.0\t0.0\t8906.0\t0.0\t18898.0\t18898.0\t18990.0\nPC.635\t9802.0\t9004.0\t0.0\t0.0\t8906.0\t0.0\t18898.0\t18898.0\t18990.0\nPC.593\t896.0\t98.0\t8906.0\t8906.0\t0.0\t8906.0\t9992.0\t9992.0\t10084.0\nPC.636\t9802.0\t9004.0\t0.0\t0.0\t8906.0\t0.0\t18898.0\t18898.0\t18990.0\nPC.355\t9096.0\t9894.0\t18898.0\t18898.0\t9992.0\t18898.0\t0.0\t0.0\t92.0\nPC.354\t9096.0\t9894.0\t18898.0\t18898.0\t9992.0\t18898.0\t0.0\t0.0\t92.0\nPC.356\t9188.0\t9986.0\t18990.0\t18990.0\t10084.0\t18990.0\t92.0\t92.0\t0.0"
     res_out = distance_matrix(StringIO.StringIO(self.fasting_map), "DOB")
     self.assertEqual(exp_out, res_out)