Exemplo n.º 1
0
                  threads,
                  verbosity=VERBOSE)
    result = op.solve(args.enumerate)

    if VERBOSE:
        print("\n", ht.now(), 'Result dataframe has been constructed...')

    result_4digit = result.applymap(get_types)
    for iii in ["A1", "A2", "B1", "B2", "C1", "C2"]:
        if not iii in result_4digit:
            result_4digit[iii] = None
    r = result_4digit[["A1", "A2", "B1", "B2", "C1", "C2", "nof_reads", "obj"]]

    # write CSV to out. And generate plots
    r.to_csv(out_csv,
             sep="\t",
             columns=["A1", "A2", "B1", "B2", "C1", "C2", "nof_reads", "obj"],
             header=["A1", "A2", "B1", "B2", "C1", "C2", "Reads", "Objective"])

    hlatype = result.iloc[0][["A1", "A2", "B1", "B2", "C1",
                              "C2"]].drop_duplicates().dropna()
    features_used = [('intron', 1), ('exon', 2), ('intron', 2), ('exon', 3), ('intron', 3)] \
                     if not args.rna else [('exon',2),('exon',3)]
    plot_variables = [
        pos, read_details, pos2, read_details2,
        (binary_p, binary_un, binary_mis)
    ] if is_paired else [pos, read_details]
    coverage_mat = ht.calculate_coverage(plot_variables, features, hlatype,
                                         features_used)
    ht.plot_coverage(out_plot, coverage_mat, table, features, features_used)
Exemplo n.º 2
0
    groups_4digit = defaultdict(list)
    for allele in allele_ids:
        type_4digit = get_4digit(allele)
        groups_4digit[type_4digit].append(allele)

    sparse_dict = ht.mtx_to_sparse_dict(compact_mtx)

    if args.verbose:
        print "\n", ht.now(), 'Initializing OptiType model...'

    op = OptiType(sparse_dict, compact_occ, groups_4digit, table, args.beta, 2,
                  config.get("OPTIMIZATION", "SOLVER"), config.get("OPTIMIZATION", "THREADS"), verbosity=verbosity)
    result = op.solve(args.enumerate)

    if args.verbose:
        print "\n", ht.now(), 'Result dataframe has been constructed...'

    result_4digit = result.applymap(get_types)
    r = result_4digit[["A1", "A2", "B1", "B2", "C1", "C2", "nof_reads", "obj"]]
    #write CSV to out. and generate Plots.  
    r.to_csv(out_csv, sep="\t",
                         cols=["A1", "A2", "B1", "B2", "C1", "C2", "nof_reads", "obj"],
                         header=["A1", "A2", "B1", "B2", "C1", "C2", "Reads", "Objective"])
    
    hlatype = result.irow(0)[["A1", "A2", "B1", "B2", "C1", "C2"]].drop_duplicates()
    features_used = [('intron', 1), ('exon', 2), ('intron', 2), ('exon', 3), ('intron', 3)] \
                     if not args.rna else [('exon',2),('exon',3)]
    plot_variables = [pos, etc, desc, pos2, etc2, desc2, binary] if is_paired else [pos, etc, desc]
    coverage_mat = ht.calculate_coverage(plot_variables, features, hlatype, features_used)
    ht.plot_coverage(out_plot, coverage_mat, table, features, features_used)