Esempio n. 1
0
        # read header first
        handle.seek(0)
        while True:
            line = handle.readline()
            peekline = handle.peekline()
            qresult_raw += line
            if not peekline.startswith(query_mark) and query_mark in peekline:
                break

        # and read the qresult raw string
        handle.seek(offset)
        while True:
            # preserve whitespace, don't use read_forward
            line = handle.readline()
            peekline = handle.peekline()
            qresult_raw += line

            # break when we've reached qresult end
            if (not peekline.startswith(query_mark) and query_mark in peekline) or \
                    not line:
                break

        # append mock end marker to qresult_raw, since it's not always present
        return qresult_raw + _as_bytes('>>><<<\n')


# if not used as a module, run the doctest
if __name__ == "__main__":
    from SAP.Bio._utils import run_doctest
    run_doctest()
Esempio n. 2
0
            from SAP.Bio.motifs import transfac
            motifs = [self]
            return transfac.write(motifs)
        else:
            raise ValueError("Unknown format type %s" % format)


def write(motifs, format):
    """Returns a string representation of motifs in a given format

    Currently supported formats (case is ignored):
     - pfm : JASPAR simple single Position Frequency Matrix
     - jaspar : JASPAR multiple PFM format
     - transfac : TRANSFAC like files
    """

    format = format.lower()
    if format in ("pfm", "jaspar"):
        from SAP.Bio.motifs import jaspar
        return jaspar.write(motifs, format)
    elif format == "transfac":
        from SAP.Bio.motifs import transfac
        return transfac.write(motifs)
    else:
        raise ValueError("Unknown format type %s" % format)


if __name__ == "__main__":
    from SAP.Bio._utils import run_doctest
    run_doctest(verbose=0)
Esempio n. 3
0
        # read header first
        handle.seek(0)
        while True:
            line = handle.readline()
            peekline = handle.peekline()
            qresult_raw += line
            if not peekline.startswith(query_mark) and query_mark in peekline:
                break

        # and read the qresult raw string
        handle.seek(offset)
        while True:
            # preserve whitespace, don't use read_forward
            line = handle.readline()
            peekline = handle.peekline()
            qresult_raw += line

            # break when we've reached qresult end
            if (not peekline.startswith(query_mark) and query_mark in peekline) or \
                    not line:
                break

        # append mock end marker to qresult_raw, since it's not always present
        return qresult_raw + _as_bytes('>>><<<\n')


# if not used as a module, run the doctest
if __name__ == "__main__":
    from SAP.Bio._utils import run_doctest
    run_doctest()
Esempio n. 4
0
        else:
            raise ValueError("Unknown format type %s" % format)


def write(motifs, format):
    """Returns a string representation of motifs in a given format

    Currently supported formats (case is ignored):
     - pfm : JASPAR simple single Position Frequency Matrix
     - jaspar : JASPAR multiple PFM format
     - transfac : TRANSFAC like files
    """

    format = format.lower()
    if format in ("pfm", "jaspar"):
        from SAP.Bio.motifs import jaspar

        return jaspar.write(motifs, format)
    elif format == "transfac":
        from SAP.Bio.motifs import transfac

        return transfac.write(motifs)
    else:
        raise ValueError("Unknown format type %s" % format)


if __name__ == "__main__":
    from SAP.Bio._utils import run_doctest

    run_doctest(verbose=0)