def promotor(self, motif):
     out = list()
     for base in list(
             Sequence.find_motif(sequence=self.seq,
                                 motif=motif,
                                 rate=99,
                                 specifity=True)):
         out.append(Series.backmelting(base=base[0])[3])
     return out
 def ekok(self, motif1, motif2):
     """
     testing...
     :param motif1:
     :param motif2:
     :return:
     """
     self.value = 0
     self.fibonacci_seq(motif1=motif1, motif2=motif2)
     a = self.fiboncci
     self.fibonacci_seq(motif1=motif2, motif2=motif1)
     b = self.fiboncci
     self.value = 1
     return Sequence.common_array_(a, b, "duo")
    def __init__(self, seq, motif1=None, motif2=None, defect=True):
        """

        :param seq: sequence
        :param motif1:first motif
        :param motif2: second motif
        :param defect: condition of defects that may occur
        """
        self.seq = seq
        self.__mtf1, self.__mtf2 = motif1, motif2
        self.__dfct = defect
        if self.__mtf1 is not None and self.__mtf2 is not None:
            self.__data__ = Sequence.distance_seq(self.seq, self.__mtf1,
                                                  self.__mtf2, "prettify",
                                                  self.__dfct)
Exemple #4
0
 def records_in(handle):
     """Generator function to iterate over fasta records as Sequence
     objects.
     """
     with handle:
         header = None
         for (is_header, lines) in groupby(handle, \
                 lambda line : line[0] == '>'):
             if is_header:
                 header = lines.next().rstrip()[1:]
             else:
                 if header:
                     seq = "".join([line.rstrip() \
                             for line in lines]).upper()
                     yield Sequence(name=header, seq=seq)
                 else:  # skip comment section
                     continue
Exemple #5
0
 def __init__(self, fn=None):
     self.seqs = []
     if fn is None:
         self.seqs = []
     elif fn != None and os.path.exists(fn):
         fi = open(fn, 'r')
         rec = []
         b = False
         for ln in fi:
             fl = ln.rstrip()
             if fl.startswith(">") and b:
                 #sq = self.createSeq(rec)
                 sn, ss = "", ""
                 for i in rec:
                     if i.startswith(">"):
                         sn = i[1:]
                     else:
                         ss = ss + i.replace(" ", "")
                 sq = Sequence(sn, ss)
                 del rec[:]
                 self.seqs.append(sq)
                 rec.append(fl)
             elif fl.startswith(">") and not b and not rec:
                 b = True
                 rec.append(fl)
             elif not fl.startswith(">"):
                 rec.append(fl)
         sn, ss = "", ""
         for i in rec:
             if i.startswith(">"):
                 sn = i[1:]
             else:
                 ss = ss + i.replace(" ", "")
             asq = AlignedSequence(sn, ss)
             del rec[:]
             self.aseqs.append(asq)
     else:
         print("File", fn, "does not exist!!")
         sys.exit()
    def get(self, iterable, specifity=False):
        """

        :param iterable:list(-nearest_distance-)
        :param specifity: id
        :return: list
        """
        put = []
        if isinstance(iterable, list):
            for base in iterable:
                main_seq, x1, x2 = Sequence.backmelting(base=base[0])[3]
                x1, x2 = int(x1), int(x2)
                sea_lane = base[1]
                side_seq = base[2]
                step_lie = base[3]
                if sea_lane == "right":
                    terminal_1 = x1
                    terminal_2 = x2 + step_lie + len(side_seq)
                    definition = self.seq[terminal_1:terminal_2]
                    if not specifity:
                        put.append(definition)
                    if specifity:
                        put.append(f'{terminal_1} <' + definition +
                                   f'<= {terminal_2}')
                if sea_lane == "left":
                    terminal_1 = x1 - step_lie - len(side_seq)
                    terminal_2 = x2
                    definition = self.seq[terminal_1:terminal_2]
                    if x1 == 0:
                        definition = self.seq[0:terminal_2]
                    if not specifity:
                        put.append(definition)
                    if specifity:
                        put.append(f'{terminal_1} <' + definition +
                                   f'<= {terminal_2}')
                if sea_lane == "adjoining":
                    terminal_1 = x1
                    terminal_2 = x2
                    definition_1 = self.seq[terminal_1 -
                                            len(side_seq):terminal_2]
                    definition_2 = self.seq[terminal_1:terminal_2 +
                                            len(side_seq)]
                    if definition_1 == main_seq + side_seq or definition_1 == side_seq + main_seq:
                        if not specifity:
                            put.append(definition_1)
                        if specifity:
                            put.append(f'{terminal_1 - len(side_seq)} <' +
                                       definition_1 + f'<= {terminal_2}')
                    if definition_2 == main_seq + side_seq or definition_2 == side_seq + main_seq:
                        if not specifity:
                            put.append(definition_2)
                        if specifity:
                            put.append(f'{terminal_1} <' + definition_2 +
                                       f'<= {terminal_2 + len(side_seq)}')
                if sea_lane == "mirror":
                    terminal_1 = x1 - len(side_seq) - step_lie
                    terminal_2 = x2 + len(side_seq) + step_lie
                    definition = self.seq[terminal_1:terminal_2]
                    if not specifity:
                        put.append(definition)
                    if specifity:
                        put.append(f'{terminal_1} <' + definition +
                                   f'<= {terminal_2}')
        return put
Exemple #7
0
def map(): return Sequence.of(0, 2, 4).map(lambda k: k * 2)
def flatMap(): return Sequence.of([{ 'data': [ 1, 2, 3 ] }, { 'data': [ 4, 5, 6 ] }]).flat_map(lambda k: k['data'])
Exemple #8
0
def terminated():
    seq = Sequence.range(0, 5)
    seq.for_each(lambda _: None)
    return seq
        testing...
        :param motif1:
        :param motif2:
        :return:
        """
        self.value = 0
        self.fibonacci_seq(motif1=motif1, motif2=motif2)
        a = self.fiboncci
        self.fibonacci_seq(motif1=motif2, motif2=motif1)
        b = self.fiboncci
        self.value = 1
        return Sequence.common_array_(a, b, "duo")


class Gen_control(Test):
    """
    testing...
    """
    value: int
    seq = str

    def __init__(self, seq):
        super(Gen_control, self).__init__(seq)


if __name__ == "__main__":
    gen = Gen_control(Sequence.random_seq(100))
    gen.value = 20
    fib = gen.fibonacci_seq("TA", "CC")
    print(gen.fiboncci)
Exemple #10
0
def iterate(): return Sequence.iterate(0, lambda k: k + 1, lambda k: k < 5)
def empty(): return Sequence.empty()
Exemple #11
0
def empty(): return Sequence.empty()

def terminated():
Exemple #12
0
def ofObjects(): return Sequence.of({ 'prop1': 'asd', 'prop2': 50 }, { 'prop1': 'asd', 'prop2': 20 }, { 'prop1': 'kek', 'prop2': 10 })
def filter(): return Sequence.of(0, 1, 2, 3, 4, 5).filter(lambda k: k % 2 == 0)
Exemple #13
0
def range(): return Sequence.range(0, 10)
def rangeClosed(): return Sequence.range_closed(0, 10)
Exemple #14
0
def distinctObjects(): return Sequence.of('asd', 'sad', 'lal', 'a', 'c', 'ba').distinct(lambda k: len(k))
def descendingNumbers(): return Sequence.range(0, 5).sort_descending()
Exemple #15
0
def flatMap(): return Sequence.of([{ 'data': [ 1, 2, 3 ] }, { 'data': [ 4, 5, 6 ] }]).flat_map(lambda k: k['data'])
def take(): return Sequence.iterate(0, lambda k: k + 2).take(6)
Exemple #16
0
def distinctNumbers(): return Sequence.of(0, 2, 2, 0, 5, 10, 2, 5).distinct()
def distinctObjects(): return Sequence.of('asd', 'sad', 'lal', 'a', 'c', 'ba').distinct(lambda k: len(k))
Exemple #17
0
def skipWhile(): return Sequence.range(0, 10).skip_while(lambda k: k < 6)
def distinctNumbers(): return Sequence.of(0, 2, 2, 0, 5, 10, 2, 5).distinct()
Exemple #18
0
def takeWhile(): return Sequence.iterate(1, lambda k: k * 2).take_while(lambda k: k < 20)
def skipWhile(): return Sequence.range(0, 10).skip_while(lambda k: k < 6)
Exemple #19
0
def filter(): return Sequence.of(0, 1, 2, 3, 4, 5).filter(lambda k: k % 2 == 0)
def map(): return Sequence.of(0, 2, 4).map(lambda k: k * 2)
Exemple #20
0
def array(): return Sequence.of([ 1, 2, 3 ])
def iterate(): return Sequence.iterate(0, lambda k: k + 1, lambda k: k < 5)
Exemple #21
0
def descendingNumbers(): return Sequence.range(0, 5).sort_descending()
Exemple #22
0
def take(): return Sequence.iterate(0, lambda k: k + 2).take(6)
def skip(): return Sequence.range(0, 6).skip(3)
Exemple #23
0
def rangeClosed(): return Sequence.range_closed(0, 10)
def array(): return Sequence.of([ 1, 2, 3 ])
Exemple #24
0
def of(): return Sequence.of(0, 1, 2, 3)
def ofObjects(): return Sequence.of({ 'prop1': 'asd', 'prop2': 50 }, { 'prop1': 'asd', 'prop2': 20 }, { 'prop1': 'kek', 'prop2': 10 })