Skip to content
Snippets Groups Projects
Commit 1ad7ceb8 authored by root's avatar root
Browse files

Update API

parent 42b73546
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -18,6 +18,9 @@ from api.models.post_refinement_cycles_model import PostRefinementCycles
from api.models.ligand_model import Ligand
from api.models.ligand_statistics_model import LigandStatistics
from api.models.ligand_solutions_model import LigandSolutions
from api.models.reference_model import Reference
from api.models.structurefactors_model import StructureFactors
from api.models.mtzfile_model import MTZ
# Activate logger
logger=logging.getLogger('dataproc')
......@@ -31,23 +34,24 @@ def storeProcInput(request):
if request.method=='POST':
json_data=json.loads(request.body)
json_data_report=json_data['GPhL_pipedream']
json_data_ligand=json_data['ligandfitting']['ligands']['1']
json_data_rc=json_data['refinement']['Cycles']
json_data_prc=json_data['ligandfitting']['ligands']['1']['postrefinement']['cycles']
json_data_solutions=json_data['ligandfitting']['ligands']['1']['solutions']
json_data_statistics=json_data['ligandfitting']['ligands']['1']['validationstatistics']['ligandstatistics']
logger.info(json_data_statistics)
logger.info(json_data_solutions)
# json_data_report=json_data['GPhL_pipedream']
# json_data_ligand=json_data['ligandfitting']['ligands']['1']
# json_data_rc=json_data['refinement']['Cycles']
# json_data_prc=json_data['ligandfitting']['ligands']['1']['postrefinement']['cycles']
# json_data_solutions=json_data['ligandfitting']['ligands']['1']['solutions']
# json_data_statistics=json_data['ligandfitting']['ligands']['1']['validationstatistics']['ligandstatistics']
json_data_reference=json_data['dataprocessing']['referencedata']['cell']
# json_data_mtz=json_data['dataprocessing']
try:
report=storeParseReport(json_data_report)
ligand=storeParseLigand(json_data_ligand, report)
storeParseRC(json_data_rc, report)
storeParsePRC(json_data_prc, ligand)
storeParseLigandSolutions(json_data_solutions, ligand)
storeParseLigandStatistics(json_data_statistics, ligand)
# report=storeParseReport(json_data_report)
# ligand=storeParseLigand(json_data_ligand, report)
# storeParseRC(json_data_rc, report)
# storeParsePRC(json_data_prc, ligand)
# storeParseLigandSolutions(json_data_solutions, ligand)
# storeParseLigandStatistics(json_data_statistics, ligand)
structurefactors=storeParseStructureFactors(json_data_reference)
# storeParseMTZ(json_data_mtz, structurefactors)
return JsonResponse({"STATUS": "INPUT SUCCESSFULLY REGISTERED"})
......@@ -68,12 +72,8 @@ def storeParseReport(data):
# autoprocscalingstatistics=data['dataprocessing']['processingdata']['AutoProcScalingStatistics']
# autoproc=data['dataprocessing']['processingdata']['AutoProc']
# referencedata=data['dataprocessing']['referencedata']
# postrefinement=data['ligandfitting']['ligands']['1']['postrefinement']['cycles']['2']
# molprobity=data['ligandfitting']['ligands']['1']['validationstatistics']['molprobity']
# IF TEST
report=Report(command=data['command'],
jsonversion=data['jsonversion'],
runby=data['runby'],
......@@ -237,6 +237,89 @@ def storeParseReport(data):
print(sys.exc_info()[0])
return ({"STATUS": "ERROR OCCURRED WHILE REGISTERING REPORT"})
@csrf_exempt
def storeParseStructureFactors(data):
"""
Creates nodes for
"""
try:
structurefactors=StructureFactors(
# uuid=data['uuid'],
# datatype=data['datatype'],
# processingtype=data['processingtype'],
gamma=data['gamma'],
a=data['a'],
alpha=data['alpha'],
b=data['a'],
beta=data['b'],
c=data['c'])
# rsf_source=data['rsf_source'],
# rsf_filesize=data['rsf_filesize'],
# rsf_filepath=data['rsf_filepath'])
structurefactors.save()
# structurefactors2=structurefactors.save()
# structurefactors2=structurefactors.serialize
# connectStructureFactorsRef(structurefactors2['structurefactors_node_properties']['uuid'], ref['ref_node_properties']['uuid'])
return ({"STATUS": "STRUCTURE FACTORS REGISTERED"})
except:
print(sys.exc_info()[0])
return ({"STATUS": "ERROR OCCURRED WHILE REGISTERING RC"})
# @csrf_exempt
# def storeParseReferenceData(data, ref):
# """
# Creates nodes for
# """
# try:
# structurefactors=StructureFactors(uuid=data['uuid'],
# datatype=data['datatype'],
# processingtype=data['processingtype'],
# gamma=data['gamma'],
# a=data['a'],
# alpha=data['alpha'],
# b=data['a'],
# beta=data['b'],
# c=data['c'],
# rsf_source=data['rsf_source'],
# rsf_filesize=data['rsf_filesize'],
# rsf_filepath=data['rsf_filepath'])
# structurefactors.save()
# structurefactors2=structurefactors.serialize
# connectStructureFactorsRef(structurefactors2['structurefactors_node_properties']['uuid'], ref['ref_node_properties']['uuid'])
# return ({"STATUS": "REF DATA REGISTERED"})
# except:
# print(sys.exc_info()[0])
# return ({"STATUS": "ERROR OCCURRED WHILE REGISTERING RC"})
@csrf_exempt
def storeParseMTZ(data, structurefactors):
"""
Creates nodes for
"""
try:
mtz=MTZ(datatype=data['datatype'])
mtz.save()
mtz2=mtz.serialize
# connectStructureFactorsMTZ(structurefactors['structurefactors_node_properties']['uuid'], mtz2['mtz_node_properties']['uuid'])
return ({"STATUS": "MTZ DATATYPE REGISTERED"})
except:
print(sys.exc_info()[0])
return ({"STATUS": "ERROR OCCURRED WHILE REGISTERING RC"})
@csrf_exempt
def storeParseRC(data, report):
......@@ -450,3 +533,32 @@ def connectLigandPRC(data1, data2):
except:
return JsonResponse({"STATUS": "ERROR OCCURRED WHILE CONNECTING LIGAND TO PRCs"}, safe=False)
@csrf_exempt
def connectStructureFactorsRef(data1, data2):
"""
Create a relationship between a SF (Structure factors) and Reference node.
"""
try:
structurefactors=StructureFactors.nodes.get(uuid=data1)
ref=Reference.nodes.get(uuid=data2)
return JsonResponse({"STATUS": structurefactors.labelled.connect(ref)}, safe=False)
except:
return JsonResponse({"STATUS": "ERROR OCCURRED WHILE CONNECTING STRUCTURE FACTORS TO REFERENCE"}, safe=False)
@csrf_exempt
def connectStructureFactorsMTZ(data1, data2):
"""
Create a relationship between a SF (Structure factors) and MTZ node.
"""
try:
structurefactors=StructureFactors.nodes.get(uuid=data1)
mtz=MTZ.nodes.get(uuid=data2)
return JsonResponse({"STATUS": structurefactors.is_mtz.connect(mtz)}, safe=False)
except:
return JsonResponse({"STATUS": "ERROR OCCURRED WHILE CONNECTING STRUCTURE FACTORS TO MTZ"}, safe=False)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment