Ejemplo n.º 1
0
def _make_isomir_counts(data, srna_type="seqbuster", out_dir=None, stem=""):
    """
    Parse miraligner files to create count matrix.
    """
    work_dir = dd.get_work_dir(data[0][0])
    if not out_dir:
        out_dir = op.join(work_dir, "mirbase")
    out_novel_isomir = append_stem(op.join(out_dir, "counts.tsv"), stem)
    out_novel_mirna = append_stem(op.join(out_dir, "counts_mirna.tsv"), stem)
    logger.debug("Create %s count data at %s." % (srna_type, out_dir))
    if file_exists(out_novel_mirna):
        return [out_novel_mirna, out_novel_isomir]
    out_dts = []
    for sample in data:
        if sample[0].get(srna_type):
            miraligner_fn = sample[0][srna_type]
            reads = _read_miraligner(miraligner_fn)
            if reads:
                out_file, dt, dt_pre = _tab_output(reads, miraligner_fn + ".back", dd.get_sample_name(sample[0]))
                out_dts.append(dt)
            else:
                logger.debug("WARNING::%s has NOT miRNA annotated for %s. Check if fasta files is small or species value." % (dd.get_sample_name(sample[0]), srna_type))
    if out_dts:
        out_files = _create_counts(out_dts, out_dir)
        out_files = [move_safe(out_files[0], out_novel_isomir), move_safe(out_files[1], out_novel_mirna)]
        return out_files
    else:
        logger.debug("WARNING::any samples have miRNA annotated for %s. Check if fasta files is small or species value." % srna_type)
Ejemplo n.º 2
0
def _make_isomir_counts(data):
    """
    Parse miraligner files to create count matrix.
    """
    work_dir = dd.get_work_dir(data[0][0])
    out_dir = os.path.join(work_dir, "mirbase")
    out_dts = []
    for sample in data:
        miraligner_fn = sample[0]["seqbuster"]
        reads = _read_miraligner(miraligner_fn)
        if reads:
            out_file, dt = _tab_output(reads, miraligner_fn + ".back",
                                       dd.get_sample_name(sample[0]))
            out_dts.append(dt)
        else:
            logger.log(
                "WARNING::%s has NOT miRNA annotated. Check if fasta files is small or species value."
                % dd.get_sample_name(sample[0]))
    if out_dts:
        out_files = _create_counts(out_dts, out_dir)
    else:
        logger.log(
            "WARNING::any samples have miRNA annotated. Check if fasta files is small or species value."
        )
    return out_files
Ejemplo n.º 3
0
def _make_isomir_counts(data):
    """
    Parse miraligner files to create count matrix.
    """
    work_dir = dd.get_work_dir(data[0][0])
    out_dir = os.path.join(work_dir, "mirbase")
    out_dts = []
    for sample in data:
        miraligner_fn = sample[0]["seqbuster"]
        reads = _read_miraligner(miraligner_fn)
        if reads:
            out_file, dt = _tab_output(reads, miraligner_fn + ".back", dd.get_sample_name(sample[0]))
            out_dts.append(dt)
        else:
            logger.log("WARNING::%s has NOT miRNA annotated. Check if fasta files is small or species value." % dd.get_sample_name(sample[0]))
    if out_dts:
        out_files = _create_counts(out_dts, out_dir)
    else:
        logger.log("WARNING::any samples have miRNA annotated. Check if fasta files is small or species value.")
    return out_files