def remove_sequence(enzyme_type, enzyme_name): ssn = SSN(enzyme_type) ssn.load() if len(list(ssn.graph.nodes)) != 0: if enzyme_name in list(ssn.graph.nodes): ssn.graph.nodes.remove(enzyme_name) ssn.save() current_app.alignment_queue.enqueue(task_expand_ssn, enzyme_type)
def task_expand_ssn(enzyme_type, log_level=1, max_num=200): current_app.app_context().push() aba_blaster = AllByAllBlaster(enzyme_type, log_level=log_level) aba_blaster.make_blast_db() ssn = SSN(enzyme_type, aba_blaster=aba_blaster, log_level=log_level) ssn.load() ssn.set_status('Checking SSN') ssn.remove_nonexisting_seqs() ssn.remove_seqs_marked_with_no_alignments() biocatdb_seqs = ssn.nodes_not_present(only_biocatdb=True, max_num=max_num) if len(biocatdb_seqs) != 0: ssn.clear_position_information() ssn.set_status('Adding and aligning BioCatDB sequences') ssn.add_multiple_proteins(biocatdb_seqs) ssn.save() current_app.alignment_queue.enqueue(new_expand_ssn_job, enzyme_type) return need_alignments = ssn.nodes_need_alignments(max_num=max_num) if len(need_alignments) != 0: ssn.clear_position_information() ssn.set_status('Aligning sequences in SSN') ssn.add_multiple_proteins(need_alignments) ssn.save() current_app.alignment_queue.enqueue(new_expand_ssn_job, enzyme_type) return not_present = ssn.nodes_not_present(max_num=max_num) if len(not_present) != 0: ssn.clear_position_information() ssn.set_status('Adding UniRef sequences which are not yet present') ssn.add_multiple_proteins(not_present) ssn.save() current_app.alignment_queue.enqueue(new_expand_ssn_job, enzyme_type) return if ssn.db_object.precalculated_vis == {} and len(ssn.graph.nodes) >= 20: ssn.set_status('Precalculating visualisations') current_app.preprocess_queue.enqueue(precalculate_job, enzyme_type) else: ssn.set_status('Complete') print(f'- SSN CONSTRUCTION FOR {enzyme_type} IS COMPLETE -') ssn.db_object.save()