Пример #1
0
def ctgs_overlap(ctg1, ctg2):
  head_seq1 = ctg_seq[ctg1][:100]
  tail_seq1 = ctg_seq[ctg1][-100:]
  head_seq2 = ctg_seq[ctg2][:100]
  tail_seq2 = ctg_seq[ctg2][-100:]

  hh_align = myalign(head_seq1, reverse_complement(head_seq2))
  hh_score = hh_align[2]
  ht_align = myalign(head_seq1, tail_seq2)
  ht_score = ht_align[2]
  th_align = myalign(tail_seq1, head_seq2)
  th_score = th_align[2]
  tt_align = myalign(tail_seq1, reverse_complement(tail_seq2))
  tt_score = tt_align[2]

  # hh_align = nw.global_align(head_seq1, reverse_complement(head_seq2))
  # hh_score = len([x for x,y in zip(*hh_align) if x == y])
  # ht_align = nw.global_align(head_seq1, tail_seq2)
  # ht_score = len([x for x,y in zip(*ht_align) if x == y])
  # th_align = nw.global_align(tail_seq1, head_seq2)
  # th_score = len([x for x,y in zip(*th_align) if x == y])
  # tt_align = nw.global_align(tail_seq1, reverse_complement(tail_seq2))
  # tt_score = len([x for x,y in zip(*tt_align) if x == y])

  scores = (hh_score, ht_score, th_score, tt_score)
  aligns  =  (hh_align, ht_align, th_align, tt_align)

  best_i = max([0,1,2,3],key=lambda x: scores[x])
  # print best_i
  # print scores[best_i]
  # print aligns[best_i][0]
  # print aligns[best_i][1]

  if scores[best_i] > 100:
    return True
Пример #2
0
def ctgs_overlap(ctg1, ctg2):
    head_seq1 = ctg_seq[ctg1][:100]
    tail_seq1 = ctg_seq[ctg1][-100:]
    head_seq2 = ctg_seq[ctg2][:100]
    tail_seq2 = ctg_seq[ctg2][-100:]

    hh_align = myalign(head_seq1, reverse_complement(head_seq2))
    hh_score = hh_align[2]
    ht_align = myalign(head_seq1, tail_seq2)
    ht_score = ht_align[2]
    th_align = myalign(tail_seq1, head_seq2)
    th_score = th_align[2]
    tt_align = myalign(tail_seq1, reverse_complement(tail_seq2))
    tt_score = tt_align[2]

    # hh_align = nw.global_align(head_seq1, reverse_complement(head_seq2))
    # hh_score = len([x for x,y in zip(*hh_align) if x == y])
    # ht_align = nw.global_align(head_seq1, tail_seq2)
    # ht_score = len([x for x,y in zip(*ht_align) if x == y])
    # th_align = nw.global_align(tail_seq1, head_seq2)
    # th_score = len([x for x,y in zip(*th_align) if x == y])
    # tt_align = nw.global_align(tail_seq1, reverse_complement(tail_seq2))
    # tt_score = len([x for x,y in zip(*tt_align) if x == y])

    scores = (hh_score, ht_score, th_score, tt_score)
    aligns = (hh_align, ht_align, th_align, tt_align)

    best_i = max([0, 1, 2, 3], key=lambda x: scores[x])
    # print best_i
    # print scores[best_i]
    # print aligns[best_i][0]
    # print aligns[best_i][1]

    if scores[best_i] > 100:
        return True
Пример #3
0
    line1 = line1[1:-1]
    if ':' in line1:
      # we have an edge
      origin, neighbors = line1.split(':')
      if origin.endswith("'"):
        origin_v = origin[:-1]
        origin_o = 1
      else:
        origin_v = origin
        origin_o = 0

      # add origin as vertex
      if origin_o == 0:
        v_seq = line2
      else:
        v_seq = reverse_complement(line2)
      add_vertex(origin_v, v_seq)

      for neighbor in neighbors.split(','):
        if neighbor.endswith("'"):
          edges.append( (origin_v, origin_o, neighbor[:-1], 1) )
        else:
          edges.append( (origin_v, origin_o, neighbor, 0) )
    else:
      # we have a vertex
      if line1.endswith("'"):
        v_name = line1[:-1]
        ori = 1
      else:
        v_name = line1
        ori = 0
Пример #4
0
        line1 = line1[1:-1]
        if ':' in line1:
            # we have an edge
            origin, neighbors = line1.split(':')
            if origin.endswith("'"):
                origin_v = origin[:-1]
                origin_o = 1
            else:
                origin_v = origin
                origin_o = 0

            # add origin as vertex
            if origin_o == 0:
                v_seq = line2
            else:
                v_seq = reverse_complement(line2)
            add_vertex(origin_v, v_seq)

            for neighbor in neighbors.split(','):
                if neighbor.endswith("'"):
                    edges.append((origin_v, origin_o, neighbor[:-1], 1))
                else:
                    edges.append((origin_v, origin_o, neighbor, 0))
        else:
            # we have a vertex
            if line1.endswith("'"):
                v_name = line1[:-1]
                ori = 1
            else:
                v_name = line1
                ori = 0