Пример #1
0
def generate_consensus(session, clone_ids):
    """Generates consensus CDR3s for clones.

    :param Session session: The database session
    :param list clone_ids: The list of clone IDs to assign to groups

    """

    if not clone_ids:
        return
    for clone in funcs.periodic_commit(session,
                                       session.query(Clone).filter(
                                           Clone.id.in_(clone_ids)),
                                       interval=1000):
        seqs = session.query(Sequence).join(SequenceCollapse).filter(
            Sequence.clone_id == clone.id,
            SequenceCollapse.copy_number_in_subject > 0).all()
        clone.cdr3_nt = funcs.consensus([s.cdr3_nt for s in seqs])
        clone.cdr3_aa = lookups.aas_from_nts(clone.cdr3_nt)

        clone.germline = generate_germline(session, seqs, clone)

        clone.overall_total_cnt = sum([s.copy_number for s in seqs])

        clone.functional = (clone.cdr3_num_nts % 3 == 0
                            and '*' not in clone.cdr3_aa
                            and not lookups.has_stop(clone.germline))

    session.commit()
Пример #2
0
def generate_germline(session, seqs, clone):
    rep_seq = seqs[0]
    cdr3_start_pos = sum(rep_seq.regions[:5])
    germline = rep_seq.germline[:cdr3_start_pos]
    germline += '-' * clone.cdr3_num_nts
    clone.functional = (len(germline) % 3 == 0
                        and not lookups.has_stop(germline))

    j_region = rep_seq.germline[cdr3_start_pos + rep_seq.cdr3_num_nts:]
    germline += j_region

    return germline
Пример #3
0
def generate_germline(session, seqs, clone):
    rep_seq = seqs[0]
    cdr3_start_pos = sum(rep_seq.regions[:5])
    germline = rep_seq.germline[:cdr3_start_pos]
    germline += '-' * clone.cdr3_num_nts
    clone.functional = (
        len(germline) % 3 == 0 and
        not lookups.has_stop(germline)
    )

    j_region = rep_seq.germline[cdr3_start_pos + rep_seq.cdr3_num_nts:]
    germline += j_region

    return germline
Пример #4
0
 def stop(self):
     return lookups.has_stop(self.sequence)
 def stop(self):
     return lookups.has_stop(self.sequence)