Example #1
0
def create_fasta_from_fastq(fastq_filename: str):
    out_lines = []
    rules = FastDNARules()
    with open(fastq_filename, "r") as in_file:
        lines = in_file.readlines()[1:][::4]
    for line in lines:
        err = rules.apply_all_rules(line[18:182])
        if err < 1.0:
            out_lines.append(line[18:182])
    with open("R:/out.fasta", "w") as out_file:
        for line in out_lines:
            out_file.write(">todo\n")
            out_file.write(line + "\n")
    return lines
Example #2
0
def fix_(in_file, out_file_str):
    correct = []
    rule = FastDNARules()
    with open(in_file, "r") as inf:
        lines = inf.readlines()
    for line in lines[1::2]:
        line = line.strip()
        if len(line) != 164:
            continue
        err_prob = rule.apply_all_rules(line)
        if err_prob < 1.0:
            correct.append((line, err_prob))
    with open(out_file_str, "w") as out_file:
        for line, err_prob in correct:
            out_file.write(f">%s\n" % err_prob)
            out_file.write(line.strip().replace("\n", "") + "\n")
    cleaned = find_dup_ids(out_file_str)
    with open(out_file_str, "w") as out_file:
        for line in cleaned:
            out_file.write(f">abc\n")
            out_file.write(line.strip().replace("\n", "") + "\n")