def add_sequence(gi, variant_model, taxonomy, header, sequence): if not variant_model.core_type.id == "H1" and not variant_model.core_type.id == "Unknown": hist_identified, ss_position, sequence = get_hist_ss(sequence, variant_model.core_type.id, save_alignment=True) sequence = str(sequence.seq) else: ss_position = defaultdict(lambda: (None, None)) sequence = str(sequence) seq = Sequence( id = gi, variant = variant_model, gene = None, splice = None, taxonomy = taxonomy, header = header, sequence = sequence, reviewed = False, ) seq.save() return seq
def update_features(seq, ss_position=None, variant_model=None, return_not_save=False): if ss_position is None and variant_model is not None: hist_identified, ss_position, sequence = get_hist_ss(seq.to_biopython(ungap=True).seq, variant_model.core_type.id, save_alignment=True) sequence = str(sequence.seq) if ss_position is None: assert 0 if hasattr(seq, "features") and seq.features: seq.features.delete() if not variant_model.core_type.id == "H1": features = Features.from_dict(seq, ss_position) if return_not_save: return features try: features.save() except: pass