Пример #1
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.Motif import Jaspar
            return Jaspar.write(self)
        elif format=="transfac":
            from Bio.Motif import TRANSFAC
            motifs = [self]
            return TRANSFAC.write(motifs)
        else:
            raise ValueError("Unknown format type %s" % format)
Пример #2
0
def write(motifs, format):
    """Returns a string representation of motifs in a given format

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

    if format=="pfm":
        from Bio.Motif 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.Motif import TRANSFAC
        return TRANSFAC.write(motifs)
    else:
        raise ValueError("Unknown format type %s" % format)