(This question is a developer question and not a user question, but since it was asked on chimera-users, the response is there as well.  Followups should go to chimera-dev@cgl.ucsf.edu.)

The "ValueError: missing default material" means that the script was not run by chimera, which we don't support.  We also don't support using an IDLE other than the one you get by running chimera and using Tools / General Tools / IDLE. 

We only support using chimera's Python code in scripts that are invoked by chimera.  That is why the ringer shell script is:

    "$CHIMERA_HOME"/bin/chimera --nogui --silent --script "$RINGER"/ringer/main.py -- "$@"

In the same vein, if you replaced "$RINGER"/ringer/main.py with the following 2 line script:

    import chimera
    print chimera.MaterialColor(1, 1, 1)

Everything works.

Long ago, we considered what it would take to get chimera's Python code working in a different application.  In that scenario, you would need to:

    1. Set the CHIMERA environment variable to the root of the Chimera installation
    2. Set other environment variables that are set in CHIMERA/bin/chimera for your platform
    3. Add $CHIMERA/share to your Python's sys.path
    4. import chimeraInit; chimeraInit.init([], nogui=True, eventloop=False, exitonquit=False)

But since chimera uses a modified Python, that is insufficient.  For example, chimera changes
Python's default string to unicode conversion to use utf-8 instead of ASCII.  We've also backported some of Python 3's unicode support that chimera depends on.  If you are lucky, your use of chimera's Python code will not be affected by those changes.

    HTH,

    Greg

P.S.  Your immediate problem might be fixed by calling chimera.initializeColors(), but that is a hack that is not guaranteed to keep working.

On 01/16/2015 12:20 PM, Alejandro Virrueta wrote:
Hello,

I am modifying some Ringer files for my own needs, but I am running into a weird issue. If I run Ringer via typical means:

$RINGER/ringer/ringer -i ringer_in_${pdb_ID}.txt -o ringer_out_${pdb_ID}.txt

it works fine. However, when I step through it in what I think is my version of IDLE ("$CHIMERA_HOME/bin/chimera --nogui --nostatus --script `which idle2.7`
/usr/bin/idle2.7", with `which idle2.7` returning "/usr/bin/idle2.7"), I run into this error:

Traceback (most recent call last):
  File "/Users/av376/ringer-2.0/ringer/main_copy.py", line 233, in <module>
    main()
  File "/Users/av376/ringer-2.0/ringer/main_copy.py", line 161, in main
    move_set, pdb = structureFile(parameters, path)
  File "/Users/av376/ringer-2.0/ringer/main_copy.py", line 65, in structureFile
    pdb = chimera.openModels.open(parameters.pdbfileName)
  File "/Applications/Chimera.app/Contents/Resources/share/chimera/__init__.py", line 1817, in open
    checkForChanges=False, noprefs=noprefs)
  File "/Applications/Chimera.app/Contents/Resources/share/chimera/__init__.py", line 1644, in add
    makePseudoBondsToMetals(realMolecules)
  File "/Applications/Chimera.app/Contents/Resources/share/chimera/__init__.py", line 1961, in makePseudoBondsToMetals
    cmPBG = mol.metalComplexGroup(issueHint=True)
  File "/Applications/Chimera.app/Contents/Resources/share/chimera/__init__.py", line 119, in _getMetalPbg
    am.color = preferences.get(MOLECULE_DEFAULT, MOL_COMPLEX_COLOR)
  File "/Applications/Chimera.app/Contents/Resources/share/chimera/preferences/base.py", line 608, in get
    forPrefSave=forPrefSave)
  File "/Applications/Chimera.app/Contents/Resources/share/chimera/preferences/base.py", line 179, in get
    return self._options[name].get(forPrefSave=forPrefSave)
  File "/Applications/Chimera.app/Contents/Resources/share/chimera/preferences/base.py", line 80, in get
    return self.prefToVal(self.value)
  File "/Applications/Chimera.app/Contents/Resources/share/chimera/tkoptions.py", line 1229, in _prefToColor
    return getColorByName(pref)
  File "/Applications/Chimera.app/Contents/Resources/share/chimera/colorTable.py", line 87, in getColorByName
    color = chimera.MaterialColor(r/255.0, g/255.0, b/255.0)
ValueError: missing default material

Any suggestions?

Cheers,
Alex


_______________________________________________
Chimera-users mailing list
Chimera-users@cgl.ucsf.edu
http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users