Пример #1
0
class AlignAceConsumer:
    """
    The general purpose consumer for the AlignAceScanner.

    Should be passed as the consumer to the feed method of the AlignAceScanner. After 'consuming' the file, it has the list of motifs in the motifs property.
    """

    def __init__(self):
        self.motifs = []
        self.current_motif = None
        self.param_dict = None

    def parameters(self, line):
        self.param_dict = {}

    def parameter(self, line):
        par_name = line.split("=")[0].strip()
        par_value = line.split("=")[1].strip()
        self.param_dict[par_name] = par_value

    def sequences(self, line):
        self.seq_dict = []

    def sequence(self, line):
        seq_name = line.split("\t")[1]
        self.seq_dict.append(seq_name)

    def motif(self, line):
        self.current_motif = Motif()
        self.motifs.append(self.current_motif)
        self.current_motif.alphabet = IUPAC.unambiguous_dna

    def motif_hit(self, line):
        seq = Seq(line.split("\t")[0], IUPAC.unambiguous_dna)
        self.current_motif.add_instance(seq)

    def motif_score(self, line):
        self.current_motif.score = float(line.split()[-1])

    def motif_mask(self, line):
        self.current_motif.set_mask(line.strip("\n\c"))

    def noevent(self, line):
        pass

    def version(self, line):
        self.ver = line

    def command_line(self, line):
        self.cmd_line = line
Пример #2
0
class AlignAceConsumer:
    """
    The general purpose consumer for the AlignAceScanner.

    Should be passed as the consumer to the feed method of the AlignAceScanner. After 'consuming' the file, it has the list of motifs in the motifs property.
    """
    def __init__(self):
        self.motifs = []
        self.current_motif = None
        self.param_dict = None

    def parameters(self, line):
        self.param_dict = {}

    def parameter(self, line):
        par_name = line.split("=")[0].strip()
        par_value = line.split("=")[1].strip()
        self.param_dict[par_name] = par_value

    def sequences(self, line):
        self.seq_dict = []

    def sequence(self, line):
        seq_name = line.split("\t")[1]
        self.seq_dict.append(seq_name)

    def motif(self, line):
        self.current_motif = Motif()
        self.motifs.append(self.current_motif)
        self.current_motif.alphabet = IUPAC.unambiguous_dna

    def motif_hit(self, line):
        seq = Seq(line.split("\t")[0], IUPAC.unambiguous_dna)
        self.current_motif.add_instance(seq)

    def motif_score(self, line):
        self.current_motif.score = float(line.split()[-1])

    def motif_mask(self, line):
        self.current_motif.set_mask(line.strip("\n\c"))

    def noevent(self, line):
        pass

    def version(self, line):
        self.ver = line

    def command_line(self, line):
        self.cmd_line = line
Пример #3
0
def createMaskedReferences(refFn, motifStr):
    # Read input files
    refRecs = [MaskedReference(rec) for rec in FastaReader(refFn)]
    maskedMs = [Motif(m) for m in motifStr.split(',')] if motifStr else []

    # Mask repeat regions
    for motif in maskedMs:
        for rec in refRecs:
            rec.MaskRepeat(motif)

    return refRecs
Пример #4
0
def do_globalAlignment(rep1, rep2):
    # Aligment
    align_dict = dict()
    BASE = "rep1"
    align_dict['rep1'] = alignment.pairwise_NW(rep1, rep1, 2, -1, -3, 1)[2]
    align_dict['rep2'] = alignment.pairwise_NW(rep1, rep2, 2, -1, -3, 1)[2]

    # get 'Match Matrix' and 'Gap List'
    matchMatrix, gapSeqList = StructMatchGap3.structMatchGap(align_dict, BASE)
    stageMatrixResult = StageMatrix.stageMatrix(matchMatrix, gapSeqList)
    Motif_Obj = Motif(stageMatrixResult, BASE)
    outputStage = OutputStage(stageMatrixResult, None, BASE, Motif_Obj)

    executionTrace_dict = {"rep1": rep1, "rep2": rep2}

    commonMotif = CommonMotif(stageMatrixResult, Motif_Obj,
                              executionTrace_dict, outputStage)

    # comMotifdict= {'s<stage>_<motif>': [CMS], oriIdxRange1, oriIdxRange2},
    comMotif_dict = commonMotif.getComMotifDict()
    return comMotif_dict
Пример #5
0
 def motif(self, line):
     self.current_motif = Motif()
     self.motifs.append(self.current_motif)
     self.current_motif.alphabet = IUPAC.unambiguous_dna
Пример #6
0
 def motif(self,line):
     self.current_motif = Motif()
     self.motifs.append(self.current_motif)
     self.current_motif.alphabet=IUPAC.unambiguous_dna
Пример #7
0
def _from_sites(handle):
    return Motif().from_jaspar_sites(handle)
Пример #8
0
def _from_pfm(handle):
    return Motif().from_jaspar_pfm(handle)
Пример #9
0
 def __init__(self):
     Motif.__init__(self)
     self.evalue = 0.0
Пример #10
0
 def __init__ (self):
     Motif.__init__(self)
     self.evalue = 0.0