Example #1
0
def write(motifs, format):
    """Return a string representation of motifs in the given format.

    Currently supported formats (case is ignored):
     - clusterbuster: Cluster Buster position frequency matrix format
     - 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 Bio.motifs import jaspar

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

        return transfac.write(motifs)
    elif format == "clusterbuster":
        from Bio.motifs import clusterbuster

        return clusterbuster.write(motifs)
    else:
        raise ValueError("Unknown format type %s" % format)
Example #2
0
    def __format__(self, format_spec):
        """Return a string representation of the Motif in the given format.

        Currently supported formats:
         - clusterbuster: Cluster Buster position frequency matrix format
         - pfm : JASPAR single Position Frequency Matrix
         - jaspar : JASPAR multiple Position Frequency Matrix
         - transfac : TRANSFAC like files

        """
        if format_spec in ("pfm", "jaspar"):
            from Bio.motifs import jaspar

            motifs = [self]
            return jaspar.write(motifs, format_spec)
        elif format_spec == "transfac":
            from Bio.motifs import transfac

            motifs = [self]
            return transfac.write(motifs)
        elif format_spec == "clusterbuster":
            from Bio.motifs import clusterbuster

            motifs = [self]
            return clusterbuster.write(motifs)
        else:
            raise ValueError("Unknown format type %s" % format_spec)
Example #3
0
    def format(self, format):
        """Returns a string representation of the Motif in a given format

        Currently supported fromats:
         - pfm : JASPAR Position Frequency Matrix
         - transfac : TRANSFAC like files
        """

        if format=="pfm":
            from Bio.motifs import jaspar
            return jaspar.write(self)
        elif format=="transfac":
            from Bio.motifs import transfac
            motifs = [self]
            return transfac.write(motifs)
        else:
            raise ValueError("Unknown format type %s" % format)
Example #4
0
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 Bio.motifs import jaspar
        return jaspar.write(motifs, format)
    elif format == "transfac":
        from Bio.motifs import transfac
        return transfac.write(motifs)
    else:
        raise ValueError("Unknown format type %s" % format)
Example #5
0
    def format(self, format):
        """Return a string representation of the Motif in the given format.

        Currently supported fromats:
         - pfm : JASPAR single Position Frequency Matrix
         - jaspar : JASPAR multiple Position Frequency Matrix
         - transfac : TRANSFAC like files

        """
        if format in ('pfm', 'jaspar'):
            from Bio.motifs import jaspar
            motifs = [self]
            return jaspar.write(motifs, format)
        elif format == "transfac":
            from Bio.motifs import transfac
            motifs = [self]
            return transfac.write(motifs)
        else:
            raise ValueError("Unknown format type %s" % format)
Example #6
0
    def format(self, format):
        """Return a string representation of the Motif in the given format.

        Currently supported fromats:
         - pfm : JASPAR single Position Frequency Matrix
         - jaspar : JASPAR multiple Position Frequency Matrix
         - transfac : TRANSFAC like files

        """
        if format in ('pfm', 'jaspar'):
            from Bio.motifs import jaspar
            motifs = [self]
            return jaspar.write(motifs, format)
        elif format == "transfac":
            from Bio.motifs import transfac
            motifs = [self]
            return transfac.write(motifs)
        else:
            raise ValueError("Unknown format type %s" % format)
Example #7
0
def write(motifs, format):
    """Returns a string representation of motifs in a given format

    Currently supported fromats (case is ignored):
     - pfm : JASPAR Position Frequency Matrix
             [only if len(motifs)==1]
     - transfac : TRANSFAC like files
    """

    format = format.lower()
    if format=="pfm":
        from Bio.motifs import jaspar
        if len(motifs)!=1:
            raise Exception("Only a single motif can be written in the JASPAR Position Frequency Matrix (pfm) format")
        motif = motifs[0]
        return jaspar.write(motif)
    elif format=="transfac":
        from Bio.motifs import transfac
        return transfac.write(motifs)
    else:
        raise ValueError("Unknown format type %s" % format)