示例#1
0
def main():
    make_dir("./data/")

    #	print sorted morbidmap
    genes = parse_morbidmap()
    with open("./data/sorted_morbidmap.txt", "w") as out:
        for dmim, gmims in sorted(genes.items()):
            out.write("#{0}|{1}\n".format(dmim, "|".join(gmims)))


#	determine the distribution of # of genes per disease
    names = defaultdict(set)
    for dmim, gmims in genes.items():
        names[len(gmims)].add(dmim)

    for i, dmims in names.items():
        print "i {0} len() {1}".format(i, len(dmims))
示例#2
0
def convert_csv_to_xls(csv_file_path, output_dir):
    """
    将csv文件转换成xls文件。
    :param csv_file_path: csv文件路径或者csv文件所在的目录。
    :param output_dir: 输出目录。
    :return: =0表示成功,否则失败。
    """

    if not os.path.exists(csv_file_path):
        print('csv file %s not exist' % csv_file_path)
        return -1

    if os.path.isfile(csv_file_path):
        if file_util.make_dir(output_dir) != 0:
            print('failed to make output dir %s' % output_dir)
            return -1

        base_filename = file_util.base_filename(csv_file_path)
        xls_file_path = '%s%s%s%s' % (output_dir, os.path.sep, base_filename,
                                      xls_filename_ext())

        try:
            workbook = xlsxwriter.Workbook(xls_file_path)
            worksheet = workbook.add_worksheet()

            with open(csv_file_path, 'rb') as f:
                csv_content = csv.reader(f)

                for row_idx, row in enumerate(csv_content):
                    for col_idx, cell in enumerate(row):
                        worksheet.write(row_idx, col_idx,
                                        cell.strip().decode('utf-8'))

            workbook.close()

            print('=== convert ' + csv_file_path + ' to ' + xls_file_path +
                  ' done ===')
            return 0
        except Exception as e:
            print('exception: %s' % e)
            return -1
    else:
        sub_csv_file_path_list = glob.glob(csv_file_path + os.path.sep +
                                           '*.csv')

        if 0 == len(sub_csv_file_path_list):
            return -1

        for i, f in enumerate(sub_csv_file_path_list):
            convert_csv_to_xls(f, output_dir)

    return 0
示例#3
0
            'INCLUDE',
            'LIB',
            'PATH',
        ]
        for var in required_vars:
            if not var in os.environ.keys():
                raise Exception('%s environment variable must be set' % var)

        # Windows custom toolchain requirements. See comments in gn_args.py.
        gn_args['visual_studio_path'] = os.environ['GYP_MSVS_OVERRIDE_PATH']
        gn_args['visual_studio_version'] = os.environ['GYP_MSVS_VERSION']
        gn_args['visual_studio_runtime_dirs'] = os.environ['VS_CRT_ROOT']
        gn_args['windows_sdk_path'] = os.environ['SDK_ROOT']

configs = GetAllPlatformConfigs(gn_args)
for dir, config in configs.items():
    # Create out directories and write the args.gn file.
    out_path = os.path.join(src_dir, 'out', dir)
    make_dir(out_path, False)
    args_gn_path = os.path.join(out_path, 'args.gn')
    args_gn_contents = GetConfigFileContents(config)
    write_file(args_gn_path, args_gn_contents)

    # Generate the Ninja config.
    cmd = ['gn', 'gen', os.path.join('out', dir)]
    if 'GN_ARGUMENTS' in os.environ.keys():
        cmd.extend(os.environ['GN_ARGUMENTS'].split(' '))
    RunAction(src_dir, cmd)
    if platform == 'windows':
        issue_1999.apply(out_path)
示例#4
0
        'INCLUDE',
        'LIB',
        'PATH',
    ]
    for var in required_vars:
      if not var in os.environ.keys():
        raise Exception('%s environment variable must be set' % var)

    # Windows custom toolchain requirements. See comments in gn_args.py.
    gn_args['visual_studio_path'] = os.environ['GYP_MSVS_OVERRIDE_PATH']
    gn_args['visual_studio_version'] = os.environ['GYP_MSVS_VERSION']
    gn_args['visual_studio_runtime_dirs'] = os.environ['VS_CRT_ROOT']
    gn_args['windows_sdk_path'] = os.environ['SDK_ROOT']

configs = GetAllPlatformConfigs(gn_args)
for dir, config in configs.items():
  # Create out directories and write the args.gn file.
  out_path = os.path.join(src_dir, 'out', dir)
  make_dir(out_path, False)
  args_gn_path = os.path.join(out_path, 'args.gn')
  args_gn_contents = GetConfigFileContents(config)
  write_file(args_gn_path, args_gn_contents)

  # Generate the Ninja config.
  cmd = ['gn', 'gen', os.path.join('out', dir)]
  if 'GN_ARGUMENTS' in os.environ.keys():
    cmd.extend(os.environ['GN_ARGUMENTS'].split(' '))
  RunAction(src_dir, cmd)
  if platform == 'windows':
    issue_1999.apply(out_path)