You are here

Calling a Rosetta xml script in a Python script gives fail to validate error

4 posts / 0 new
Last post
Calling a Rosetta xml script in a Python script gives fail to validate error
#1

I tried to run the below script in Python to automate some stuff:

from datetime import datetime
from subprocess import call, Popen

startTime = datetime.now()


call(['/home/labusr/rosetta/main/source/bin/rosetta_scripts.linuxgccrelease',
      '-in::file::s /home/labusr/Documents/tubulin_exercise/5w3f_saccharomyeces_s_k40_unmodeled.pdb',
      '-parser::protocol /home/labusr/Documents/A_asymm_refine.xml',
      '-parser::script_vars denswt=35 rms=1.5 reso=4.3 map=/home/labusr/Documents/tubulin_exercise/masked_map_center.mrc testmap=/home/labusr/Documents/tubulin_exercise/mmasked_map_top_centered_resampled.mrc',
      '-in:ignore_unrecognized_res',
      '-edensity::mapreso 4.3',
      '-default_max_cycles 200 ',
      '-edensity::cryoem_scatterers',
      '-beta',
      '-out::suffix _$1',
      '-crystal_refine'])

print(datetime.now() - startTime)

 

This is the XML file:

<ROSETTASCRIPTS>
   <SCOREFXNS>
      <ScoreFunction name="cen" weights="score4_smooth_cart">
         <Reweight scoretype="elec_dens_fast" weight="20"/>
      </ScoreFunction>
      <ScoreFunction name="dens_soft" weights="beta_soft">
         <Reweight scoretype="cart_bonded" weight="0.5"/>
         <Reweight scoretype="pro_close" weight="0.0"/>
         <Reweight scoretype="elec_dens_fast" weight="%%denswt%%"/>
      </ScoreFunction>
      <ScoreFunction name="dens" weights="beta_cart">
         <Reweight scoretype="elec_dens_fast" weight="%%denswt%%"/>
         <Set scale_sc_dens_byres="R:0.76,K:0.76,E:0.76,D:0.76,M:0.76,C:0.81,Q:0.81,H:0.81,N:0.81,T:0.81,S:0.81,Y:0.88,W:0.88,A:0.88,F:0.88,P:0.88,I:0.88,L:0.88,V:0.88"/>
      </ScoreFunction>
   </SCOREFXNS>

   <MOVERS>
      <SetupForDensityScoring name="setupdens"/>
      <LoadDensityMap name="loaddens" mapfile="%%map%%"/>

      <SwitchResidueTypeSetMover name="tocen" set="centroid"/>

      <MinMover name="cenmin" scorefxn="cen" type="lbfgs_armijo_nonmonotone"
         max_iter="200" tolerance="0.00001" bb="1" chi="1" jump="ALL"/>

      <CartesianSampler name="cen5_50" automode_scorecut="-0.5" scorefxn="cen"
         mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
         rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
         nfrags="25"/>
      <CartesianSampler name="cen5_60" automode_scorecut="-0.3" scorefxn="cen"
         mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
         rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
         nfrags="25"/>
      <CartesianSampler name="cen5_70" automode_scorecut="-0.1" scorefxn="cen"
         mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
         rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
         nfrags="25"/>
      <CartesianSampler name="cen5_80" automode_scorecut="0.0" scorefxn="cen"
         mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
         rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
         nfrags="25"/>

      <ReportFSC name="report" testmap="%%testmap%%" res_low="10.0" res_high="%%reso%%"/>

      <BfactorFitting name="fit_bs" max_iter="50" wt_adp="0.0005" init="1" exact="1"/>

      <FastRelax name="relaxcart" scorefxn="dens" repeats="1" cartesian="1"/>
   </MOVERS>


   <PROTOCOLS>
      <Add mover="setupdens"/>
      <Add mover="loaddens"/>
      <Add mover="tocen"/>
      <Add mover="cenmin"/>
      <Add mover="relaxcart"/>
      <Add mover="cen5_50"/>
      <Add mover="relaxcart"/>
      <Add mover="cen5_60"/>
      <Add mover="relaxcart"/>
      <Add mover="cen5_70"/>
      <Add mover="relaxcart"/>
      <Add mover="cen5_80"/>
      <Add mover="relaxcart"/>
      <Add mover="relaxcart"/>
      <Add mover="report"/>
   </PROTOCOLS>
   <OUTPUT scorefxn="dens"/>

</ROSETTASCRIPTS>

 

This is the error I recieved. The strange thing is, when I run the same script as a bash script, I don't get any errors. 

Error: [ ERROR ] Input rosetta scripts XML file "/home/labusr/Documents/A_asymm_refine.xml" failed to validate against the rosetta scripts schema. Use the option -parser::output_schema <output filename> to output the schema to a file to see all valid options.
Your XML has failed validation.  The error message below will tell you where in your XML file the error occurred.  Here's how to fix it:

1) If the validation fails on something obvious, like an illegal attribute due to a spelling error (perhaps you used scorefnction instead of scorefunction), then you need to fix your XML file.
2) If you haven’t run the XML rewriter script and this might be pre-2017 Rosetta XML, run the rewriter script (tools/xsd_xrw/rewrite_rosetta_script.py) on your input XML first.  The attribute values not being in quotes (scorefunction=talaris2014 instead of scorefunction="talaris2014") is a good indicator that this is your problem.
3) If you are a developer and neither 1 nor 2 worked - email the developer’s mailing list or try Slack.
4) If you are an academic or commercial user - try the Rosetta Forums https://www.rosettacommons.org/forum
5)


Error messages were:
From line 9:
Error: Element 'Reweight', attribute 'weight': [facet 'pattern'] The value '35 rms=1.5 reso=4.3 map=/home/labusr/Documents/tubulin_exercise/masked_map_center.mrc testmap=/home/labusr/Documents/tubulin_exercise/mmasked_map_top_centered_resampled.mrc' is not accepted by the pattern '[-+]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?'.

 4:          <Reweight scoretype="elec_dens_fast" weight="20"/>
 5:       </ScoreFunction>
 6:       <ScoreFunction name="dens_soft" weights="beta_soft">
 7:          <Reweight scoretype="cart_bonded" weight="0.5"/>
 8:          <Reweight scoretype="pro_close" weight="0.0"/>
 9:          <Reweight scoretype="elec_dens_fast" weight="35 rms=1.5 reso=4.3 map=/home/labusr/Documents/tubulin_exercise/masked_map_center.mrc testmap=/home/labusr/Documents/tubulin_exercise/mmasked_map_top_centered_resampled.mrc"/>
10:       </ScoreFunction>
11:       <ScoreFunction name="dens" weights="beta_cart">
12:          <Reweight scoretype="elec_dens_fast" weight="35 rms=1.5 reso=4.3 map=/home/labusr/Documents/tubulin_exercise/masked_map_center.mrc testmap=/home/labusr/Documents/tubulin_exercise/mmasked_map_top_centered_resampled.mrc"/>
13:          <Set scale_sc_dens_byres="R:0.76,K:0.76,E:0.76,D:0.76,M:0.76,C:0.81,Q:0.81,H:0.81,N:0.81,T:0.81,S:0.81,Y:0.88,W:0.88,A:0.88,F:0.88,P:0.88,I:0.88,L:0.88,V:0.88"/>
14:       </ScoreFunction>
From line 9:
Error: Element 'Reweight', attribute 'weight': '35 rms=1.5 reso=4.3 map=/home/labusr/Documents/tubulin_exercise/masked_map_center.mrc testmap=/home/labusr/Documents/tubulin_exercise/mmasked_map_top_centered_resampled.mrc' is not a valid value of the atomic type 'real'.

 4:          <Reweight scoretype="elec_dens_fast" weight="20"/>
 5:       </ScoreFunction>
 6:       <ScoreFunction name="dens_soft" weights="beta_soft">
 7:          <Reweight scoretype="cart_bonded" weight="0.5"/>
 8:          <Reweight scoretype="pro_close" weight="0.0"/>
 9:          <Reweight scoretype="elec_dens_fast" weight="35 rms=1.5 reso=4.3 map=/home/labusr/Documents/tubulin_exercise/masked_map_center.mrc testmap=/home/labusr/Documents/tubulin_exercise/mmasked_map_top_centered_resampled.mrc"/>
10:       </ScoreFunction>
11:       <ScoreFunction name="dens" weights="beta_cart">
12:          <Reweight scoretype="elec_dens_fast" weight="35 rms=1.5 reso=4.3 map=/home/labusr/Documents/tubulin_exercise/masked_map_center.mrc testmap=/home/labusr/Documents/tubulin_exercise/mmasked_map_top_centered_resampled.mrc"/>
13:          <Set scale_sc_dens_byres="R:0.76,K:0.76,E:0.76,D:0.76,M:0.76,C:0.81,Q:0.81,H:0.81,N:0.81,T:0.81,S:0.81,Y:0.88,W:0.88,A:0.88,F:0.88,P:0.88,I:0.88,L:0.88,V:0.88"/>
14:       </ScoreFunction>
From line 12:
Error: Element 'Reweight', attribute 'weight': [facet 'pattern'] The value '35 rms=1.5 reso=4.3 map=/home/labusr/Documents/tubulin_exercise/masked_map_center.mrc testmap=/home/labusr/Documents/tubulin_exercise/mmasked_map_top_centered_resampled.mrc' is not accepted by the pattern '[-+]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?'.

 7:          <Reweight scoretype="cart_bonded" weight="0.5"/>
 8:          <Reweight scoretype="pro_close" weight="0.0"/>
 9:          <Reweight scoretype="elec_dens_fast" weight="35 rms=1.5 reso=4.3 map=/home/labusr/Documents/tubulin_exercise/masked_map_center.mrc testmap=/home/labusr/Documents/tubulin_exercise/mmasked_map_top_centered_resampled.mrc"/>
10:       </ScoreFunction>
11:       <ScoreFunction name="dens" weights="beta_cart">
12:          <Reweight scoretype="elec_dens_fast" weight="35 rms=1.5 reso=4.3 map=/home/labusr/Documents/tubulin_exercise/masked_map_center.mrc testmap=/home/labusr/Documents/tubulin_exercise/mmasked_map_top_centered_resampled.mrc"/>
13:          <Set scale_sc_dens_byres="R:0.76,K:0.76,E:0.76,D:0.76,M:0.76,C:0.81,Q:0.81,H:0.81,N:0.81,T:0.81,S:0.81,Y:0.88,W:0.88,A:0.88,F:0.88,P:0.88,I:0.88,L:0.88,V:0.88"/>
14:       </ScoreFunction>
15:    </SCOREFXNS>
16: 
17:    <MOVERS>
From line 12:
Error: Element 'Reweight', attribute 'weight': '35 rms=1.5 reso=4.3 map=/home/labusr/Documents/tubulin_exercise/masked_map_center.mrc testmap=/home/labusr/Documents/tubulin_exercise/mmasked_map_top_centered_resampled.mrc' is not a valid value of the atomic type 'real'.

 7:          <Reweight scoretype="cart_bonded" weight="0.5"/>
 8:          <Reweight scoretype="pro_close" weight="0.0"/>
 9:          <Reweight scoretype="elec_dens_fast" weight="35 rms=1.5 reso=4.3 map=/home/labusr/Documents/tubulin_exercise/masked_map_center.mrc testmap=/home/labusr/Documents/tubulin_exercise/mmasked_map_top_centered_resampled.mrc"/>
10:       </ScoreFunction>
11:       <ScoreFunction name="dens" weights="beta_cart">
12:          <Reweight scoretype="elec_dens_fast" weight="35 rms=1.5 reso=4.3 map=/home/labusr/Documents/tubulin_exercise/masked_map_center.mrc testmap=/home/labusr/Documents/tubulin_exercise/mmasked_map_top_centered_resampled.mrc"/>
13:          <Set scale_sc_dens_byres="R:0.76,K:0.76,E:0.76,D:0.76,M:0.76,C:0.81,Q:0.81,H:0.81,N:0.81,T:0.81,S:0.81,Y:0.88,W:0.88,A:0.88,F:0.88,P:0.88,I:0.88,L:0.88,V:0.88"/>
14:       </ScoreFunction>
15:    </SCOREFXNS>
16: 
17:    <MOVERS>
From line 29:
Error: Element 'CartesianSampler', attribute 'rms': [facet 'pattern'] The value '%%rms%%' is not accepted by the pattern '[-+]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?'.

24:          max_iter="200" tolerance="0.00001" bb="1" chi="1" jump="ALL"/>
25: 
26:       <CartesianSampler name="cen5_50" automode_scorecut="-0.5" scorefxn="cen"
27:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
28:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
29:          nfrags="25"/>
30:       <CartesianSampler name="cen5_60" automode_scorecut="-0.3" scorefxn="cen"
31:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
32:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
33:          nfrags="25"/>
34:       <CartesianSampler name="cen5_70" automode_scorecut="-0.1" scorefxn="cen"
From line 29:
Error: Element 'CartesianSampler', attribute 'rms': '%%rms%%' is not a valid value of the atomic type 'real'.

24:          max_iter="200" tolerance="0.00001" bb="1" chi="1" jump="ALL"/>
25: 
26:       <CartesianSampler name="cen5_50" automode_scorecut="-0.5" scorefxn="cen"
27:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
28:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
29:          nfrags="25"/>
30:       <CartesianSampler name="cen5_60" automode_scorecut="-0.3" scorefxn="cen"
31:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
32:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
33:          nfrags="25"/>
34:       <CartesianSampler name="cen5_70" automode_scorecut="-0.1" scorefxn="cen"
From line 33:
Error: Element 'CartesianSampler', attribute 'rms': [facet 'pattern'] The value '%%rms%%' is not accepted by the pattern '[-+]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?'.

28:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
29:          nfrags="25"/>
30:       <CartesianSampler name="cen5_60" automode_scorecut="-0.3" scorefxn="cen"
31:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
32:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
33:          nfrags="25"/>
34:       <CartesianSampler name="cen5_70" automode_scorecut="-0.1" scorefxn="cen"
35:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
36:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
37:          nfrags="25"/>
38:       <CartesianSampler name="cen5_80" automode_scorecut="0.0" scorefxn="cen"
From line 33:
Error: Element 'CartesianSampler', attribute 'rms': '%%rms%%' is not a valid value of the atomic type 'real'.

28:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
29:          nfrags="25"/>
30:       <CartesianSampler name="cen5_60" automode_scorecut="-0.3" scorefxn="cen"
31:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
32:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
33:          nfrags="25"/>
34:       <CartesianSampler name="cen5_70" automode_scorecut="-0.1" scorefxn="cen"
35:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
36:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
37:          nfrags="25"/>
38:       <CartesianSampler name="cen5_80" automode_scorecut="0.0" scorefxn="cen"
From line 37:
Error: Element 'CartesianSampler', attribute 'rms': [facet 'pattern'] The value '%%rms%%' is not accepted by the pattern '[-+]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?'.

32:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
33:          nfrags="25"/>
34:       <CartesianSampler name="cen5_70" automode_scorecut="-0.1" scorefxn="cen"
35:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
36:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
37:          nfrags="25"/>
38:       <CartesianSampler name="cen5_80" automode_scorecut="0.0" scorefxn="cen"
39:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
40:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
41:          nfrags="25"/>
42: 
From line 37:
Error: Element 'CartesianSampler', attribute 'rms': '%%rms%%' is not a valid value of the atomic type 'real'.

32:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
33:          nfrags="25"/>
34:       <CartesianSampler name="cen5_70" automode_scorecut="-0.1" scorefxn="cen"
35:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
36:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
37:          nfrags="25"/>
38:       <CartesianSampler name="cen5_80" automode_scorecut="0.0" scorefxn="cen"
39:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
40:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
41:          nfrags="25"/>
42: 
From line 41:
Error: Element 'CartesianSampler', attribute 'rms': [facet 'pattern'] The value '%%rms%%' is not accepted by the pattern '[-+]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?'.

36:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
37:          nfrags="25"/>
38:       <CartesianSampler name="cen5_80" automode_scorecut="0.0" scorefxn="cen"
39:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
40:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
41:          nfrags="25"/>
42: 
43:       <ReportFSC name="report" testmap="%%testmap%%" res_low="10.0" res_high="%%reso%%"/>
44: 
45:       <BfactorFitting name="fit_bs" max_iter="50" wt_adp="0.0005" init="1" exact="1"/>
46: 
From line 41:
Error: Element 'CartesianSampler', attribute 'rms': '%%rms%%' is not a valid value of the atomic type 'real'.

36:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
37:          nfrags="25"/>
38:       <CartesianSampler name="cen5_80" automode_scorecut="0.0" scorefxn="cen"
39:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
40:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
41:          nfrags="25"/>
42: 
43:       <ReportFSC name="report" testmap="%%testmap%%" res_low="10.0" res_high="%%reso%%"/>
44: 
45:       <BfactorFitting name="fit_bs" max_iter="50" wt_adp="0.0005" init="1" exact="1"/>
46: 
From line 43:
Error: Element 'ReportFSC', attribute 'res_high': [facet 'pattern'] The value '%%reso%%' is not accepted by the pattern '[-+]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?'.

38:       <CartesianSampler name="cen5_80" automode_scorecut="0.0" scorefxn="cen"
39:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
40:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
41:          nfrags="25"/>
42: 
43:       <ReportFSC name="report" testmap="%%testmap%%" res_low="10.0" res_high="%%reso%%"/>
44: 
45:       <BfactorFitting name="fit_bs" max_iter="50" wt_adp="0.0005" init="1" exact="1"/>
46: 
47:       <FastRelax name="relaxcart" scorefxn="dens" repeats="1" cartesian="1"/>
48:    </MOVERS>
From line 43:
Error: Element 'ReportFSC', attribute 'res_high': '%%reso%%' is not a valid value of the atomic type 'real'.

38:       <CartesianSampler name="cen5_80" automode_scorecut="0.0" scorefxn="cen"
39:          mcscorefxn="cen" fascorefxn="dens_soft" strategy="auto" fragbias="density"
40:          rms="%%rms%%" ncycles="200" fullatom="0" bbmove="1" nminsteps="25" temp="4" fraglens="7"
41:          nfrags="25"/>
42: 
43:       <ReportFSC name="report" testmap="%%testmap%%" res_low="10.0" res_high="%%reso%%"/>
44: 
45:       <BfactorFitting name="fit_bs" max_iter="50" wt_adp="0.0005" init="1" exact="1"/>
46: 
47:       <FastRelax name="relaxcart" scorefxn="dens" repeats="1" cartesian="1"/>
48:    </MOVERS>
------------------------------------------------------------
Warning messages were:
------------------------------------------------------------

Error: [ ERROR ] 
Error: [ ERROR ] Treating failure as bad input; canceling similar jobs
protocols.jd2.FileSystemJobDistributor: job failed, reporting bad input; other jobs of same input will be canceled: 5w3f_saccharomyeces_s_k40_unmodeled_$1_0001
protocols.jd2.JobDistributor: no more batches to process... 
protocols.jd2.JobDistributor: 1 jobs considered, 1 jobs attempted in 23 seconds
Error: [ ERROR ] Exception caught by rosetta_scripts application:1 jobs failed; check output for error messages
Error: [ ERROR ] 

 

Post Situation: 
Tue, 2018-03-06 08:00
ahmadkhalifa

This has to do with option parsing, specifically what the normally does for you and what you need to do yourself when using the call() function.

Normally, the shell will parse the commandline and split out each whitespace separated chunk into its own input parameter. Rosetta then takes that list of input parameters and then parses the options out of them. When you use the call() function in Python, there isn't that shell-parsing stage. It's up to you to do that parsing, separating things out appropriately. In your script you fail to do this properly. You do separate out individual Rosetta options, but you don't do the same whitespace separation within the options that the shell does.

It looks like Rosetta goes above and beyond and is able to correctly interpret things like '-edensity::mapreso 4.3'. It can do this because it knows that there are no spaces within Rosetta options, so once it hits a space, whatever follows must be the value for that. But when it does it for the -parser::script_vars option, it only splits the one space. The rest of the spaces are then intepreted as being part of what you're passing to the denswt variable.

Your call() call should look more like this:

call(['/home/labusr/rosetta/main/source/bin/rosetta_scripts.linuxgccrelease',
      '-in::file::s', '/home/labusr/Documents/tubulin_exercise/5w3f_saccharomyeces_s_k40_unmodeled.pdb',
      '-parser::protocol', '/home/labusr/Documents/A_asymm_refine.xml',
      '-parser::script_vars', 'denswt=35', 'rms=1.5', 'reso=4.3', 'map=/home/labusr/Documents/tubulin_exercise/masked_map_center.mrc', 'testmap=/home/labusr/Documents/tubulin_exercise/mmasked_map_top_centered_resampled.mrc',
      '-in:ignore_unrecognized_res',
      '-edensity::mapreso', '4.3',
      '-default_max_cycles', '200',
      '-edensity::cryoem_scatterers',
      '-beta',
      '-out::suffix', '_$1',
      '-crystal_refine'])

 

I should also mention that there are other things besides spaces that the shell does for you. These are things like globbing (substituting the wildcards in things like *.pdb), tilde expansion (substituting "/home/labusr/" for the the "~/" in paths) and variable expansion. If you're using subprocess calls directly, and not going through a shell, you need to do all of these things yourself. -- You're running into that last issue (variable expansion) with your -out:suffix parameter. In the original shell script, the shell would expand that to whatever was the first argument passed to the shell script when run. Since you're not using a shell script, you need to do the substitution yourself, otherwise you'll get a literal `_$1` in your output names. (This will cause you grief when you do use a shell with them.)

Tue, 2018-03-06 08:32
rmoretti

Thanks a lot for a detailed and eye opening reply. I will certainly take care of al lthat in Python. I wonder though if I can Pyrosetta to rewrite the xml script, or possibly call it using Pyrosetta? 

Mon, 2018-03-19 06:35
ahmadkhalifa

If you want to call a RosettaScripts XML from within PyRosetta, you can try calling the generate_mover_and_apply_to_pose() methods of the rosetta.protocols.rosetta_scripts.RosettaScriptsParser object. (Despite the name, it doesn't actually apply the mover to the pose -- the "apply_to_pose" in the method name just means that it invokes the deprecated APPLY_TO_POSE sections in the XML to the input pose.) That's not going to allow you to do finer-grained substituion of the script_vars, though, as that will attempt to automatically pull out the settings from the options object.

In general, there's a bunch of functions on the RosettaScriptsParser object which may be of use. In particular, you may want to look at the create_tag_from_xml_string() method, which is what does the script_vars substitution. You can then pass the result of that to the generate_mover_for_protocol() method to actually generate the mover. 

 

 

Mon, 2018-03-19 12:35
rmoretti