# QMean standalone evaluation

I want to use a script to evaluate a protein structure with QMEAN scoring.

I can't understand why the script suggested by SWISS-MODEL (access to QMEAN by json object) runs only if I put the commands on the shell. If I build a module, the result of the second request (request.get), return a QUEUEING status, not COMPLETE status.

Here is the code that I have been using:

import json
import requests

def qmean_page(structure):
""" return the Qmean4 score from SWISSMODEL QMEAN tool"""

url = "https://swissmodel.expasy.org/qmean/submit/"

# Request the resource
response = requests.post(url=url, data={"email": "XXX@XXX.XX"} ,files={"structure": open(structure,'r'),},timeout=3,verify=True)

json.dumps(response.json(), indent=4, sort_keys=True)

# Request the resource

scores = json.dumps(r.json(), indent=4, sort_keys=True)
print scores
zscore = jdata['input_data']['models'][0]['global_scores']['qmean4']['zscore']
return zscore

s = 'P02489.B99990005.pdb'
url_d = qmean_page(s)
print url_d
score  = qmean_score(url_d)
print score


CASE A: If I comment the last 5 line, I can import qmean.py (the function file) in python terminal.

>>> import qmean
>>> s = 'P02489.B99990005.pdb'
>>> url_d = qmean.qmean_page(s)
>>> print url_d
https://swissmodel.expasy.org/qmean/project/TgEjha.json
>>> score  = qmean.qmean_score(url_d)
{
"input_data": {
"info": {
"model_001": {
"chain_mapping": {
" ": "A"
}
}
},
"meta": {
"created": "2018-01-18T10:04:29.978",
"email": "XXX@XXX.XX",
"project_name": "Project",
},
"method": "QMEANDisCo",
"models": [
{
"error_status": null,
"global_scores": {
"acc_agreement": {
"norm": 0.5606936416184971,
"zscore": -1.0459143647477258
},
"all_atom": {
"norm": -0.012626634534455788,
"zscore": -2.1825427852787604
},
"cbeta": {
"norm": -0.004260555683274807,
"zscore": -1.9157144117276892
},
"qmean4": {
"norm": 0.6275190794418422,
"zscore": -3.5006904416158258
},
"qmean6": {
"norm": 0.6339071011931049,
"zscore": -3.0507104571131918
},
"solvation": {
"norm": -0.609099435253941,
"zscore": -1.2499924754236265
},
"ss_agreement": {
"norm": 0.6706229586994028,
"zscore": 0.05371252044245716
},
"torsion": {
"norm": 0.0033300496230023145,
"zscore": -2.7188811736675764
}
},
"model_pdb": "https://swissmodel.expasy.org/qmean/project/TgEjha/model_001.pdb",
"modelid": "model_001",
"name": "P02489.B99990005.pdb",
"seqres": [
{
"chain_name": " ",
"name": "seq_chain_0",
}
]
}
],
"options": {
"qmeanbrane": false,
"qmeandisco": true
},
"project_type": "default",
"sequences": []
},
"status": "COMPLETED"
}
>>>


CASE B: If I uncomment the last 5 lines and run 'python qmean.py', it doesn't work.

  andrea\$ python qmean.py
https://swissmodel.expasy.org/qmean/project/zrcLCK.json
{
"status": "QUEUEING"
}
Traceback (most recent call last):
File "qmean.py", line 31, in <module>
score  = qmean_score(url_d)
File "qmean.py", line 24, in qmean_score
zscore = jdata['input_data']['models'][0]['global_scores']['qmean4']['zscore']
KeyError: 'input_data'


If I print 'r' variable of 'qmean_score' function, It returns:

  <Response [200]>
{
"status": "QUEUEING"
}

• You need to use if __main__: if you want to use that file as a module and in command line. But what is your question? You seem to have solved your problems. – llrs Jan 18 '18 at 9:23
• No, it is not solved because I could have a result like case A also when I call my function as case B – Andrea Spinelli Jan 18 '18 at 13:34
• I resolve the problem by using a while loop. – Andrea Spinelli Jan 22 '18 at 16:14
• maybe you could post your answer and accept it, for people trying to figure out what was the issue, or delete your question if you think that it won't be useful for other people. – aechchiki Feb 19 '18 at 10:41

So this is connected to how QMEAN is implemented as a server. It also could be true to many bioinformatics resources so I think this is important.

Posting to QMEAN "submit" triggers the job that is processed on our HPC cluster. That takes time and in the meantime JSON response just tells you that the job is QUEUEING/RUNNING or when it is ready it tells you COMPLETED. The answer suggested by you is the correct assuming you wish to wait for the job completion (which might take quite a lot).

So just check in while loop when the status is COMPLETED and fetch the result eg.

import time
import json
import requests
# Request the resource
zscore = None
while True: