コード例 #1
0
def draw_light_heavy_graph(directory):
    analysis_path = os.path.join(directory, "analysis")

    heavy_path = os.path.join(analysis_path, "heavy.fa")
    light_path = os.path.join(analysis_path, "light.fa")

    heavy = read_fasta(heavy_path)
    light = read_fasta(light_path)

    heavy_clusters = load_clusters(analysis_path, "heavy")
    light_clusters = load_clusters(analysis_path, "light")

    heavy_nodes = get_node_lists(heavy)
    light_nodes = get_node_lists(light)

    heavy_colors = color_nodes(heavy_nodes, heavy_clusters)
    light_colors = color_nodes(light_nodes, light_clusters)
    colors = unify_pair(heavy_colors, light_colors)

    heavy_labels = get_labels(heavy_nodes)
    light_labels = get_labels(light_nodes)
    labels = unify_pair(heavy_labels, light_labels)

    hl_edges = get_edges_list(heavy_nodes, light_nodes)
    edges = unify_edges(len(heavy_nodes), hl_edges, labels)

    G = nx.Graph()
    G.add_nodes_from(get_vertices(edges))
    G.add_edges_from(edges)
    nx.draw_networkx(G, color=colors)
    plt.savefig(os.path.join(analysis_path, "connections.pdf"))
コード例 #2
0
def process(directory,
            similarity_name="similarity",
            minlen=100,
            shead=0,
            prct=1.):
    similarity_dir = os.path.join(directory, similarity_name)
    if os.path.isdir(similarity_dir):
        shutil.rmtree(similarity_dir)
    os.mkdir(similarity_dir)

    common = get_common_name(directory, "-amino-aligned.fa")
    print(common)
    light = process_one(
        similarity_dir, "light",
        read_fasta(
            os.path.join(directory, common + "light-chains-amino-aligned.fa"),
            False), minlen, shead, prct)
    heavy = process_one(
        similarity_dir, "heavy",
        read_fasta(
            os.path.join(directory, common + "heavy-chains-amino-aligned.fa"),
            False), minlen, shead, prct)

    with open(os.path.join(similarity_dir, "report.htm"), "wt") as fd:
        fd.write(generate_report(heavy, light, minlen, shead, prct))
コード例 #3
0
def process(directory, analysis_name="analysis", prct=False):
    analysis_dir = os.path.join(directory, analysis_name)
    if os.path.isdir(analysis_dir):
        shutil.rmtree(analysis_dir)
    os.mkdir(analysis_dir)

    common = get_common_name(directory, "-amino-aligned.fa")
    process_one(analysis_dir, "light", read_fasta(os.path.join(directory, common + "light-chains-amino-aligned.fa"),
                                                  False), prct)
    process_one(analysis_dir, "heavy", read_fasta(os.path.join(directory, common + "heavy-chains-amino-aligned.fa"),
                                                  False), prct)
コード例 #4
0
def load_clusters(directory, strtype):
    result = []
    clusters_dir = os.path.join(os.path.join(directory, strtype), "clusters")
    for cluster in filter(lambda x: x.endswith(".fasta") or x.endswith(".fa"),
                          os.listdir(clusters_dir)):
        result.append(read_fasta(os.path.join(clusters_dir, cluster), False))
    return result
コード例 #5
0
def process(directory, similarity_name="similarity", minlen=100, shead=0, prct=1.):
    similarity_dir = os.path.join(directory, similarity_name)
    if os.path.isdir(similarity_dir):
        shutil.rmtree(similarity_dir)
    os.mkdir(similarity_dir)

    common = get_common_name(directory, "-amino-aligned.fa")
    print(common)
    light = process_one(similarity_dir, "light", read_fasta(os.path.join(directory,
                                                                         common + "light-chains-amino-aligned.fa"),
                                                            False), minlen, shead, prct)
    heavy = process_one(similarity_dir, "heavy", read_fasta(os.path.join(directory,
                                                                         common + "heavy-chains-amino-aligned.fa"),
                                                            False), minlen, shead, prct)

    with open(os.path.join(similarity_dir, "report.htm"), "wt") as fd:
        fd.write(generate_report(heavy, light, minlen, shead, prct))
コード例 #6
0
def make_alignments(clusterdir):
    for cluster in os.listdir(clusterdir):
        logging.debug("cluster: {}".format(cluster))
        fasta = read_fasta(os.path.join(clusterdir, cluster), False)
        pos = cluster.rfind('.')
        name = cluster[:pos]
        with open(os.path.join(clusterdir, "{}.htm".format(name)), "wt") as fd:
            fd.write(make_document(name, fasta))
コード例 #7
0
def process(directory, analysis_name="analysis", prct=False):
    analysis_dir = os.path.join(directory, analysis_name)
    if os.path.isdir(analysis_dir):
        shutil.rmtree(analysis_dir)
    os.mkdir(analysis_dir)

    common = get_common_name(directory, "-amino-aligned.fa")
    process_one(
        analysis_dir, "light",
        read_fasta(
            os.path.join(directory, common + "light-chains-amino-aligned.fa"),
            False), prct)
    process_one(
        analysis_dir, "heavy",
        read_fasta(
            os.path.join(directory, common + "heavy-chains-amino-aligned.fa"),
            False), prct)
コード例 #8
0
def make_alignments(clusterdir):
    for cluster in os.listdir(clusterdir):
        logging.debug("cluster: {}".format(cluster))
        fasta = read_fasta(os.path.join(clusterdir, cluster), False)
        pos = cluster.rfind('.')
        name = cluster[:pos]
        with open(os.path.join(clusterdir, "{}.htm".format(name)), "wt") as fd:
            fd.write(make_document(name, fasta))
コード例 #9
0
 def run(self):
     prct = False if not self.radio_confidence.isChecked() else float(self.spinadd.value()) / 100
     out = str(self.linein.text())
     if self.radio_sanger.isChecked():
         analysis_dir = "analysis"
         process(out, analysis_dir, prct)
         hl_process(os.path.join(out, analysis_dir), prct)
     else:
         analysis_dir = os.path.dirname(out)
         chain = os.path.basename(out)
         chain = chain[:chain.rfind(".")] + "-analysis"
         process_one(analysis_dir, chain, read_fasta(out, False), prct)
     self.lok.setText("READY")
コード例 #10
0
ファイル: alignment.py プロジェクト: zmactep/ig-assist-tools
def multiple_alignment_use_files(file_input, alignment_type=SeqTypeData().TYPE_DEFAULT):
    muscle_cmd = SeqTypeData().type2cmd_f[alignment_type]
    result = iterpipes.run(iterpipes.linecmd(str(muscle_cmd) + " -in \"" + file_input + "\""))
    result_list = []
    for i in result:
        result_list.append(i.strip())
    # iores = StringIO()
    # for i in result_list:
    #     print(i[0])
    #     iores.write(i)
    name = file_input[:file_input.rfind('.')] + "-aligned.fa"
    with open(name, "wt") as tmpfd:
        tmpfd.write("\n".join(result_list))
    return fasta_tools.read_fasta(name, False)
コード例 #11
0
def load_chains(directory, suffix):
    filenames = list(filter(lambda f: f.endswith(suffix), os.listdir(directory)))
    heavy_chains = FastaDict()
    light_chains = FastaDict()
    logging.debug("Creating VL and VH arrays")
    for filename in filenames:
        name = os.path.join(directory, filename)
        fd = read_fasta(name)
        for seq in fd.keys():
            if seq.endswith(CHAIN_MARKER_VL):
                light_chains.set(seq, fd.get(seq))
            elif seq.endswith(CHAIN_MARKER_VH):
                heavy_chains.set(seq, fd.get(seq))
    return light_chains, heavy_chains
コード例 #12
0
 def run(self):
     minlen = 100 if not self.radio_confidence.isChecked() else int(self.spinmin.value())
     shead = 0 if not self.radio_confidence.isChecked() else self.spinaddh.value()
     prct = 1. if not self.radio_confidence.isChecked() else float(self.spinaddt.value()) / 100
     out = str(self.linein.text())
     if self.radio_sanger.isChecked():
         analysis_dir = "similarity"
         process(out, analysis_dir, minlen, shead, prct)
     else:
         analysis_dir = os.path.dirname(out)
         chain = os.path.basename(out)
         chain = chain[:chain.rfind(".")] + "-similarity"
         process_one(analysis_dir, chain, read_fasta(out, False), minlen, shead, prct)
     self.lok.setText("READY")
コード例 #13
0
ファイル: alignment.py プロジェクト: zmactep/ig-assist-tools
def multiple_alignment_use_files(file_input,
                                 alignment_type=SeqTypeData().TYPE_DEFAULT):
    muscle_cmd = SeqTypeData().type2cmd_f[alignment_type]
    result = iterpipes.run(
        iterpipes.linecmd(str(muscle_cmd) + " -in \"" + file_input + "\""))
    result_list = []
    for i in result:
        result_list.append(i.strip())
    # iores = StringIO()
    # for i in result_list:
    #     print(i[0])
    #     iores.write(i)
    name = file_input[:file_input.rfind('.')] + "-aligned.fa"
    with open(name, "wt") as tmpfd:
        tmpfd.write("\n".join(result_list))
    return fasta_tools.read_fasta(name, False)
コード例 #14
0
 def run(self):
     minlen = 100 if not self.radio_confidence.isChecked() else int(
         self.spinmin.value())
     shead = 0 if not self.radio_confidence.isChecked(
     ) else self.spinaddh.value()
     prct = 1. if not self.radio_confidence.isChecked() else float(
         self.spinaddt.value()) / 100
     out = str(self.linein.text())
     if self.radio_sanger.isChecked():
         analysis_dir = "similarity"
         process(out, analysis_dir, minlen, shead, prct)
     else:
         analysis_dir = os.path.dirname(out)
         chain = os.path.basename(out)
         chain = chain[:chain.rfind(".")] + "-similarity"
         process_one(analysis_dir, chain, read_fasta(out, False), minlen,
                     shead, prct)
     self.lok.setText("READY")
コード例 #15
0
def load_clusters(directory, strtype):
    result = []
    clusters_dir = os.path.join(os.path.join(directory, strtype), "clusters")
    for cluster in filter(lambda x: x.endswith(".fasta") or x.endswith(".fa"), os.listdir(clusters_dir)):
        result.append(read_fasta(os.path.join(clusters_dir, cluster), False))
    return result
コード例 #16
0
def load_clusters(directory, strtype):
    result = []
    clusters_dir = os.path.join(os.path.join(directory, strtype), "clusters")
    for cluster in os.listdir(clusters_dir):
        result.append(read_fasta(os.path.join(clusters_dir, cluster)))
    return result