def papers_with_orhpan_sequences(): title = "Papers with orphan sequences" activity_enzyme_names = list( set(Activity.objects().distinct('enzyme_name'))) paper_ids = [] for name in activity_enzyme_names: if len(Sequence.objects(enzyme_name=name)) == 0: act = Activity.objects(enzyme_name=name)[0] paper_ids.append(act.paper) papers_data = list( Paper.objects(id__in=paper_ids).only( *papers_table.PAPERS_TABLE_FIELDS).order_by( '-status').as_pymongo()) papers_data = papers_table.process_papers_dict(papers_data, show_owner=False) return render_template('edit_tables/edit_papers.html', papers_data=papers_data, papers_table_height='80vh', papers_button_columns=['delete', 'edit'], show_owner=True, title=title, row_click_modal=False)
def clear_databases(): EnzymeType.drop_collection() Sequence.drop_collection() Paper.drop_collection() Reaction.drop_collection() Activity.drop_collection() Molecule.drop_collection()
def set_choices(self): self.enzymes.choices = [ (c, c) for c in ['All'] + (list(Activity.objects().distinct('enzyme_type'))) ] self.reactions.choices = [ (c, c) for c in ['All'] + (list(Activity.objects().distinct('reaction'))) ]
def task_search_for_orphan_enzymes(): activity_enzyme_names = list( set(Activity.objects().distinct('enzyme_name'))) for name in activity_enzyme_names: if len(Sequence.objects(enzyme_name=name)) == 0: enzyme_type = Activity.objects(enzyme_name=name)[0].enzyme_type new_seq = Sequence(enzyme_name=name, enzyme_type=enzyme_type) new_seq.save() print( f"found orphan enzyme, added sequence entry for {name} - {enzyme_type}" )
def merge_sequences(): to_merge = request.form['to_merge'] merge_with = request.form['merge_with'] status = 'success' msg = 'Sequences merged' issues = [] if to_merge != merge_with: seq = Sequence.objects(enzyme_name=to_merge)[0] seq_merge = Sequence.objects(enzyme_name=merge_with)[0] if seq.enzyme_type == seq_merge.enzyme_type: for paper in seq.papers: seq_merge.papers.append(paper) acts = Activity.objects(enzyme_name=to_merge) for act in acts: act.enzyme_name = seq_merge.enzyme_name act.save() seq.delete() seq_merge.other_names.append(to_merge) seq_merge.save() update_seq_papers_status(merge_with) else: status = 'danger' msg = 'Could not merge sequences' issues.append('Enzyme types must be the same') else: status = 'danger' msg = 'Could not merge sequences' issues.append('Cannot merge with self') result = {'status': status, 'msg': msg, 'issues': issues} return jsonify(result=result)
def delete_sequence(): to_delete = request.form['to_delete'] seq = Sequence.objects(enzyme_name=to_delete)[0] acts = Activity.objects(enzyme_name=to_delete) status = 'success' msg = 'Sequence deleted' issues = [] if len(acts) != 0: status = 'danger' msg = 'Could not delete' papers = [] for act in acts: if act.short_citation not in papers: papers.append(act.short_citation) for paper in papers: issues.append(f"Sequence is recorded in activity data for {paper}") mutants = Sequence.objects(mutant_of=to_delete) if len(mutants) != 0: status = 'danger' msg = 'Could not delete' for mut in mutants: issues.append(f"Sequence is a parent of mutant {mut.enzyme_name}") if status == 'success': seq.delete() result = {'status': status, 'msg': msg, 'issues': issues} return jsonify(result=result)
def raise_activity_data_issue(): user = user_datastore.get_user(current_user.id) activity_id = request.form['activity_id'] comment = request.form['comment'] activity = Activity.objects(id=activity_id)[0].select_related() comment_obj = Comment(owner=user, text=comment) comment_obj.save() if len(ActivityIssue.objects(activity=activity)) == 0: new_issue = ActivityIssue(activity=activity, raised_by=user, comments=[comment_obj]) new_issue.save() result = { 'status': 'success', 'msg': 'Issue has been created', 'issues': [] } return jsonify(result=result) else: result = { 'status': 'danger', 'msg': 'An issue has already been raised for this data', 'issues': ['Please see the activity data issues page for more information'] } return jsonify(result=result)
def delete_old_autoprocessed(self, paper): pq = db.Q(paper=paper) ap = db.Q(auto_generated=True) acts = Activity.objects(pq & ap) for act in acts: act.delete()
def add_to_db(self, new_df, paper): if len(new_df) != 0: self.log(f"..adding {len(new_df)} new activity rows") for i, row in new_df.iterrows(): if row['binary'] == 1: binary = True else: binary = False if row['auto_generated'] == 1: auto_gen = True else: auto_gen = False activity = Activity( enzyme_type=check_is_nan(row['enzyme_type']), enzyme_name=check_is_nan(row['enzyme_name']), reaction=check_is_nan(row['reaction']), short_citation=check_is_nan(row['short_citation']), html_doi=check_is_nan(row['html_doi']), added_by_string=str(row['added_by_string']), paper=paper, substrate_1_smiles=get_smile(row['substrate_1_smiles']), substrate_2_smiles=get_smile(row['substrate_2_smiles']), product_1_smiles=get_smile(row['product_1_smiles']), temperature=check_is_nan(row['temperature']), ph=check_is_nan(row['ph']), solvent=check_is_nan(row['solvent']), other_conditions=check_is_nan(row['other_conditions']), notes=check_is_nan(row['notes']), reaction_vol=check_is_nan(row['reaction_vol']), formulation=check_is_nan(row['formulation']), biocat_conc=check_is_nan(row['biocat_conc']), kcat=check_is_float(row['kcat']), km=check_is_float(row['km']), mw=check_is_float(row['mw']), substrate_1_conc=check_is_nan(row['substrate_1_conc']), substrate_2_conc=check_is_nan(row['substrate_2_conc']), specific_activity=check_is_float(row['specific_activity']), conversion=check_is_float(row['conversion']), conversion_time=check_is_float(row['conversion_time']), categorical=check_is_nan(row['categorical']), binary=binary, selectivity=check_is_nan(row['selectivity']), auto_generated=auto_gen) activity.save()
def clear_autoprocessed_activity_data(): activity_data = Activity.objects(auto_generated=True) for act in activity_data: act.delete() result = { 'status': 'success', 'msg': f'Autoprocessed data deleted', 'issues': [] } return jsonify(result=result)
def admin_activity_to_owner(): paper = Paper.objects(id=request.form['paper_id']).select_related()[0] activities = Activity.objects(paper=paper) for activity in activities: activity.added_by = paper.owner activity.save() result = { 'status': 'success', 'msg': 'Activity added by updated', 'issues': [] } return jsonify(result=result)
def submission_main_page(paper_id): user = user_datastore.get_user(current_user.id) paper_query = Paper.objects(id=paper_id).select_related() if len(paper_query) == 0: flash('Paper has not been added yet, please add to the database first', 'fail') return redirect(url_for("biocatdb.launch_add_paper")) paper = paper_query[0] if not check_permission.check_paper_permission(current_user.id, paper): flash('No access to edit this entry', 'fail') return redirect(url_for("biocatdb.launch_add_paper")) paper_data = get_paper_data(paper, user) activity_data = get_activity_data(paper) reactions = list(Reaction.objects().distinct('name')) enzyme_names = list(Sequence.objects(papers=paper).distinct('enzyme_name')) enzyme_types = list(EnzymeType.objects().distinct('enzyme_type')) enzyme_data = sequence_table.get_enzyme_data(db.Q(papers=paper)) enzyme_types_in_paper = list(Sequence.objects(papers=paper).distinct('enzyme_type')) reactions_in_paper = list(Reaction.objects(enzyme_types__in=enzyme_types_in_paper).distinct('name')) reactions_in_activity = list(Activity.objects(paper=paper).distinct('reaction')) status_dict = get_status(paper, user) comments = get_comments(paper, user) paper_molecules = get_paper_molecules(paper) admin_panel = False admin_dict = {} if current_user.has_role('admin'): admin_panel = True admin_dict = get_admin_dict(paper) reactions_ordered = reactions_in_activity + [r for r in reactions_in_paper if r not in reactions_in_activity] reactions_ordered += [r for r in reactions_in_paper if r not in reactions_ordered] reactions_ordered += [r for r in reactions if r not in reactions_ordered] return render_template('data_submission/submission_main_page.html', paper=paper_data, activity_data=activity_data, seq_data=enzyme_data, seq_button_columns=['edit', 'remove', 'papers'], status=status_dict, seq_table_height='60vh', enzyme_types=enzyme_types, show_header_filters=False, include_owner=True, lock_enz_type='false', reactions=reactions_ordered, enzyme_names=enzyme_names+['Chemical'], doi=paper.doi, comments=comments, paper_molecules=paper_molecules, admin_panel=admin_panel, admin_dict=admin_dict, enzyme_reactions=reactions_in_paper)
def enzyme_substrate_specificity(enzyme_name): title = f"{enzyme_name} substrate specificity" args = request.args.to_dict() if 'reviewed' in args: revQ = db.Q(reviewed=True) else: revQ = db.Q() title += " (including not reviewed)" enzNameQ = db.Q(enzyme_name=enzyme_name) activity_data = list(Activity.objects(enzNameQ & revQ).only(*process_activity_data.mongo_cols).as_pymongo()) activity_data = process_activity_data.process_activity_data(activity_data) activity_data = process_activity_data.smiles_to_svg(activity_data) return render_template('substrate_specificity/table_result_specificity.html', substrate_specificity_data=activity_data, title=title)
def paper_substrate_specificity(paper_id): paper = Paper.objects(id=paper_id)[0] title = f"{paper.short_citation} activity data" args = request.args.to_dict() if 'reviewed' in args: revQ = db.Q(reviewed=True) else: revQ = db.Q() paper_Q = db.Q(paper=paper) activity_data = list(Activity.objects(paper_Q & revQ).only(*process_activity_data.mongo_cols).as_pymongo()) activity_data = process_activity_data.process_activity_data(activity_data) activity_data = process_activity_data.smiles_to_svg(activity_data) return render_template('substrate_specificity/table_result_specificity.html', substrate_specificity_data=activity_data, title=title)
def activity_status(paper): progress = 5 progress_text = "Please add activity data" activity = Activity.objects(paper=paper) if len(activity) != 0: progress = 90 progress_text = "Activity data added, please ensure all activity data (including negative data) is included. Awaiting review." if paper.reviewed == True: progress = 100 progress_text = 'Complete' return progress_text, str(progress) + '%' else: return progress_text, str(progress) + '%'
def change_enzyme_type_name(enz_type, new_name): print("Updating enzyme types..") old_name = enz_type.enzyme_type for seq in Sequence.objects(enzyme_type=old_name): seq.enzyme_type = new_name seq.save() for reaction in Reaction.objects(enzyme_types=old_name): reaction.enzyme_types.remove(old_name) reaction.enzyme_types.append(new_name) reaction.cofactors[new_name] = reaction.cofactors.pop(old_name) reaction.save() for activity in Activity.objects(enzyme_type=old_name): activity.enzyme_type = new_name activity.save() print('..done')
def get_activity_data(paper): include = ['id', "reaction", "enzyme_name", "substrate_1_smiles", "substrate_2_smiles", "product_1_smiles", "temperature", "ph", "solvent", "other_conditions", "notes", "reaction_vol", "formulation", "biocat_conc", "kcat", "km", "mw", "substrate_1_conc", "substrate_2_conc", "specific_activity", "conversion", "conversion_time", "selectivity", "categorical", "binary", ] q_paper = db.Q(paper=paper) q_not_automated = db.Q(auto_generated__ne=True) activity_data = list(Activity.objects(q_paper & q_not_automated).only(*include).as_pymongo()) for i, data in enumerate(activity_data): activity_data[i]['_id'] = str(activity_data[i]['_id']) if activity_data[i]['binary']: activity_data[i]['binary'] = 1 else: activity_data[i]['binary'] = 0 return activity_data
def delete_enzyme_types(): to_delete = request.form['to_delete'] enz_type = EnzymeType.objects(enzyme_type=to_delete)[0] seqs = Sequence.objects(enzyme_type=to_delete) reacs = Reaction.objects(enzyme_types=to_delete) acts = Activity.objects(enzyme_type=to_delete) status = 'success' msg = 'Enzyme type deleted' issues = [] if len(seqs) != 0: status = 'danger' msg = 'Could not delete' for seq in seqs: issues.append( f'Enzyme type is present in sequence: {seq.enzyme_name}') if len(reacs) != 0: status = 'danger' msg = 'Could not delete' for reac in reacs: issues.append(f'Enzyme type is present in reaction: {reac.name}') if len(acts) != 0: status = 'danger' msg = 'Could not delete' papers = [] for act in acts: if act.short_citation not in papers: papers.append(act.short_citation) for paper in papers: issues.append( f"Enzyme type is recorded in activity data for {paper}") if status == 'success': enz_type.delete() result = {'status': status, 'msg': msg, 'issues': issues} return jsonify(result=result)
def update_reviewed_status(): papers = Paper.objects(reviewed=True) for paper in papers: acts = Activity.objects(paper=paper) seqs = Sequence.objects(papers=paper) for act in acts: act.reviewed = True act.save() for seq in seqs: seq.reviewed = True seq.save() result = { 'status': 'success', 'msg': f'Updated activity and sequence data to reviewed = True, if paper has been reviewed', 'issues': [] } return jsonify(result=result)
def enzyme_substrate_specificity_type(enzyme_type): title = f"Substrate scope for all {enzyme_type} enzymes" if enzyme_type == 'All': enz_type_q = db.Q() title += " (including not reviewed)" else: enz_type_q = db.Q(enzyme_type=enzyme_type) args = request.args.to_dict() if 'reviewed' in args: revQ = db.Q(reviewed=True) else: revQ = db.Q() activity_data = list(Activity.objects(enz_type_q & revQ).only(*process_activity_data.mongo_cols).as_pymongo()) activity_data = process_activity_data.process_activity_data(activity_data) activity_data = process_activity_data.smiles_to_svg(activity_data) return render_template('substrate_specificity/table_result_specificity.html', substrate_specificity_data=activity_data, title=title)
def review_paper(): user = user_datastore.get_user(current_user.id) paper = Paper.objects(id=request.form['paper_id'])[0] acts = Activity.objects(paper=paper) seqs = Sequence.objects(papers=paper).select_related() if check_permission.check_seq_permissions(current_user.id, paper): reviewed = bool(strtobool(request.form['reviewed'])) paper.reviewed = reviewed if reviewed == True: paper.reviewed_by = user else: paper.reviewed_by = None paper.save() for act in acts: act.reviewed = reviewed act.save() if reviewed == True: for seq in seqs: seq.reviewed = True seq.save() else: for seq in seqs: has_reviewed_paper = False for paper in seq.papers: if paper.reviewed == True: has_reviewed_paper = True break if has_reviewed_paper == False: seq.reviewed = False seq.save() result = { 'status': 'success', 'msg': 'Review status updated', 'issues': [] } return jsonify(result=result)
def task_assign_papers(): users = User.objects() papers = Paper.objects() for paper in papers: paper_status.update_status(paper) for user in users: usernames = get_usernames(user) for paper in papers: if paper.added_by is None or paper.added_by == '': activities = Activity.objects(paper=paper) for activity in activities: if does_username_match(usernames, activity.added_by_string): activity.added_by = user activity.save() if paper.added_by is None or paper.added_by == '': paper.added_by = user paper.owner = user paper.save()
def remove_sequence(): user = user_datastore.get_user(current_user.id) paper = Paper.objects(id=request.form['paper_id'])[0] enzyme_name = request.form['enzyme_name'] seq = Sequence.objects(enzyme_name=enzyme_name)[0] if len( Activity.objects( db.Q(enzyme_name=seq.enzyme_name) & db.Q(paper=paper))) != 0: result = { 'status': 'danger', 'msg': 'Can not remove sequence - activity data still attached', 'issues': [ 'Please remove references to this sequence in the activity section before removing' ] } return jsonify(result=result) else: if paper in seq.papers: seq.papers.remove(paper) seq.save() if len(seq.papers) == 0 and (seq.sequence == '' or seq.sequence is None): seq.delete() papers_functions.tag_paper_with_enzyme_types(paper) result = { 'status': 'success', 'msg': 'Sequence removed from paper', 'issues': [] } flash("Sequence removed from paper", 'success') return jsonify(result=result)
def query_specificity_data(listReactions, listEnzymes, only_reviewed=False): if "All" in listEnzymes or len(listEnzymes) == 0 or listEnzymes == ['']: enzQ = Q() else: enzQ = Q(enzyme_type__in=listEnzymes) if "All" in listReactions or len(listReactions) == 0 or listReactions == [ '' ]: reacQ = Q() else: reacQ = Q(reaction__in=listReactions) if only_reviewed == True: revQ = Q(reviewed=True) else: revQ = Q() result = Activity.objects(enzQ & reacQ & revQ).as_pymongo() spec_df = pd.DataFrame(list(result)) spec_df = organise_mongo_columns(spec_df) return spec_df
def delete_paper(): user = user_datastore.get_user(current_user.id) paper = Paper.objects(id=request.form['paper_id'])[0] if not check_permission.check_paper_permission(current_user.id, paper): result = { 'status': 'danger', 'msg': 'You are not the owner of this paper', 'issues': ['Assign this paper to yourself in order to delete it'] } return jsonify(result=result) elif len(Sequence.objects(papers=paper)) != 0: result = { 'status': 'danger', 'msg': 'Paper still contains sequences', 'issues': ['Please remove any sequences from paper before deleting'] } return jsonify(result=result) elif len(Activity.objects(paper=paper)) != 0: result = { 'status': 'danger', 'msg': 'Paper still contains activity data', 'issues': ['Please remove any activity data from paper before deleting'] } return jsonify(result=result) else: paper.delete() result = {'status': 'success', 'msg': 'Paper deleted', 'issues': []} return jsonify(result=result)
def save_reaction(): rxn_selection = request.form['rxn_selection'] rxn_name = request.form['rxn_name'] smarts_yaml = request.form['smarts_yaml'] cofactors = request.form['cofactors'] positive_tests = request.form['positive_tests'] negative_tests = request.form['negative_tests'] rxn_type = request.form['rxn_type'] experimental = request.form['experimental'] two_step = request.form['two_step'] requires_absence_of_water = request.form['requires_absence_of_water'] if experimental == 'false': experimental = False elif experimental == 'true': experimental = True if two_step == 'false': two_step = False elif two_step == 'true': two_step = True if requires_absence_of_water == 'false': requires_absence_of_water = False elif requires_absence_of_water == 'true': requires_absence_of_water = True if rxn_selection == 'Empty template': if len(Reaction.objects(name=rxn_name)) == 0 and rxn_name != '': reaction = Reaction(name=rxn_name) else: result = { 'status': 'failed', 'msg': "Could not create new reaction - name already exists", 'issues': [] } return jsonify(result=result) else: reaction = Reaction.objects(name=rxn_selection)[0] if len(Reaction.objects(name=rxn_name)) == 0: reaction.name = rxn_name reaction.smarts = yaml.load(smarts_yaml, Loader=yaml.FullLoader) reaction.enzyme_types = list( yaml.load(cofactors, Loader=yaml.FullLoader).keys()) reaction.cofactors = yaml.load(cofactors, Loader=yaml.FullLoader) reaction.positive_tests = yaml.load(positive_tests, Loader=yaml.FullLoader) reaction.negative_tests = yaml.load(negative_tests, Loader=yaml.FullLoader) reaction.type = rxn_type reaction.experimental = experimental reaction.two_step = two_step reaction.requires_absence_of_water = requires_absence_of_water reaction.save() refresh = 'False' if rxn_selection != reaction.name: refresh = 'True' activities = Activity.objects(reaction=rxn_selection) for act in activities: act.reaction = reaction.name act.save() print("reaction saved") result = { 'status': 'info', 'msg': "Reaction saved", 'issues': [], 'refresh': refresh } return jsonify(result=result)
def get_enzymes_in_db(): enzymes = Activity.objects().distinct('enzyme_type') return enzymes
def get_reactions_in_db(): reactions = Activity.objects().distinct('reaction') return reactions
def init_db(): form = InitDB() if form.validate_on_submit() == True: if form.rxns.data != None: rxns_data = form.rxns.data filename = secure_filename(rxns_data.filename) try: rxns_data.save(filename) yaml_dict = rxn_rules_to_db.load_yaml_dict(filename) Reaction.drop_collection() current_app.db_queue.enqueue(rxn_rules_to_db.load_into_mongo, yaml_dict) flash("Yaml loaded ok, reactions_to_db in queue", 'success') except: flash("Failed to load reactions", 'fail') os.remove(filename) if form.biocatdb.data != None: filename = secure_filename(form.biocatdb.data.filename) form.biocatdb.data.save(filename) try: df = biocatdb_excel_to_db.load_df(filename) Paper.drop_collection() Activity.drop_collection() Molecule.drop_collection() Sequence.drop_collection() current_app.db_queue.enqueue(biocatdb_excel_to_db.df_to_db, df) current_app.db_queue.enqueue(make_molecule_db.make_fp_db) flash("Biocatdb excel loaded ok, added to queue", "success") except: flash("Problem loading biocatdb_2 excel", "fail") os.remove(filename) if form.sequences.data != None: filename = secure_filename(form.sequences.data.filename) form.sequences.data.save(filename) try: if '.xlsx' in filename: df = pd.read_excel(filename) elif '.csv' in filename: df = pd.read_csv(filename) else: df = None Exception('File must be .csv or .xlsx') current_app.db_queue.enqueue(task_add_sequence_data, df) flash("Sequences excel loaded ok, added to queue", "success") except Exception as e: flash(f"Problem loading sequences excel - {e}", "fail") os.remove(filename) if form.mongo_dump.data != None: filename = secure_filename(form.mongo_dump.data.filename) form.mongo_dump.data.save(filename) try: if 'mongo_dump.gz' in filename: execute_mongo_restore(filename) else: Exception('File must be mongo_dump.gz') flash("mongo dump loaded ok", "success") except Exception as e: flash(f"Problem loading mongo dump - {e}", "fail") return render_template('init_db/init_db.html', form=form)
def df_to_db(spec_df): #added_by_dict = make_added_by_user_dict() print('Saving biocatdb_2 excel to mongodb..') for i, row in spec_df.iterrows(): html_doi = str(row['html_doi']) doi = str(row['html_doi']) added_by_string = str(row['added_by']) list_html_to_remove = [ 'https://doi.org/', 'http://doi.org/', 'http://dx.doi.org/' ] for to_remove in list_html_to_remove: if to_remove in doi: doi = html_doi.replace(to_remove, '') if len(Paper.objects(doi=doi)) == 0: paper = Paper(short_citation=str(row['short_citation']), html=html_doi, doi=doi) paper = paper.save() print(f"{row['short_citation']} added") else: paper = Paper.objects(doi=doi)[0] if row['enzyme_type'] is not None and row['enzyme_type'] != '' and type( row['enzyme_type']) == str: if len(EnzymeType.objects(enzyme_type=row['enzyme_type'])) == 0: enz_type = EnzymeType(enzyme_type=row['enzyme_type'], description='') enz_type.save() if row['enzyme_name'] is not None and row['enzyme_name'] != '' and type( row['enzyme_name']) == str: if len(Sequence.objects(enzyme_name=row['enzyme_name'])) == 0: seq = Sequence(enzyme_name=check_is_nan(row['enzyme_name']), enzyme_type=check_is_nan(row['enzyme_type']), papers=[paper]) seq.save() else: seq = Sequence.objects(enzyme_name=row['enzyme_name'])[0] if paper not in seq.papers: seq.papers.append(paper) seq = seq.save() if row['binary'] == 1: binary = True else: binary = False if row['auto_generated'] == 1: auto_gen = True else: auto_gen = False activity = Activity( enzyme_type=check_is_nan(row['enzyme_type']), enzyme_name=check_is_nan(row['enzyme_name']), reaction=check_is_nan(row['reaction']), short_citation=check_is_nan(row['short_citation']), html_doi=check_is_nan(row['html_doi']), added_by_string=added_by_string, paper=paper, cascade_num=check_is_nan(row['cascade_num']), substrate_1_smiles=get_smile(row['substrate_1_smiles']), substrate_2_smiles=get_smile(row['substrate_2_smiles']), product_1_smiles=get_smile(row['product_1_smiles']), temperature=check_is_nan(row['temperature']), ph=check_is_nan(row['ph']), solvent=check_is_nan(row['solvent']), other_conditions=check_is_nan(row['other_conditions']), notes=check_is_nan(row['notes']), reaction_vol=check_is_nan(row['reaction_vol']), formulation=check_is_nan(row['formulation']), biocat_conc=check_is_nan(row['biocat_conc']), kcat=check_is_float(row['kcat']), km=check_is_float(row['km']), mw=check_is_float(row['mw']), substrate_1_conc=check_is_nan(row['substrate_1_conc']), substrate_2_conc=check_is_nan(row['substrate_2_conc']), specific_activity=check_is_float(row['specific_activity']), conversion=check_is_float(row['conversion']), conversion_time=check_is_float(row['conversion_time']), categorical=check_is_nan(row['categorical']), binary=binary, selectivity=check_is_nan(row['selectivity']), auto_generated=auto_gen) activity.save() print('..done')