コード例 #1
0
def identify_lasso_motifs(
        leader: str, core: str) -> Tuple[List[int], int, Dict[int, float]]:
    """Run FIMO to identify lasso peptide-specific motifs"""
    motif_file = path.get_full_path(__file__, 'data', "lasso_motifs_meme.txt")
    with TemporaryFile() as tempfile:
        out_file = open(tempfile.name, "w")
        out_file.write(">query\n%s%s" % (leader, core))
        out_file.close()
        fimo_output = subprocessing.run_fimo_simple(motif_file, tempfile.name)
    fimo_motifs = [
        int(line.partition("\t")[0]) for line in fimo_output.split("\n")
        if "\t" in line and line.partition("\t")[0].isdigit()
    ]
    fimo_scores = {
        int(line.split("\t")[0]): float(line.split("\t")[5])
        for line in fimo_output.split("\n")
        if "\t" in line and line.partition("\t")[0].isdigit()
    }
    # Calculate score
    motif_score = 0
    if 2 in fimo_motifs:
        motif_score += 4
    elif fimo_motifs:
        motif_score += 2
    else:
        motif_score += -1
    return fimo_motifs, motif_score, fimo_scores
コード例 #2
0
def identify_lanthi_motifs(leader: str, core: str) -> Dict[int, float]:
    """Run FIMO to identify lanthipeptide-specific motifs"""
    motifs_file = path.get_full_path(__file__, "data", "lanthi_motifs_meme.txt")
    with NamedTemporaryFile() as tempfile:
        out_file = open(tempfile.name, "w")
        out_file.write(">query\n%s%s" % (leader, core))
        out_file.close()
        fimo_output = subprocessing.run_fimo_simple(motifs_file, tempfile.name)
    fimo_scores = {}
    for line in fimo_output.splitlines():
        parts = line.split("\t")
        if len(parts) < 2 or not parts[0].isdigit():
            continue
        fimo_scores[int(parts[0])] = float(parts[5])
    return fimo_scores