Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:RBVI/ChimeraX into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
elainecmeng committed Oct 27, 2023
2 parents 3d13bc5 + 6aa4b8e commit 5d3df79
Show file tree
Hide file tree
Showing 27 changed files with 143 additions and 91 deletions.
4 changes: 2 additions & 2 deletions src/bundles/alphafold/src/alphafold21_predict_colab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@
"# We have to use \"--no-warn-conflicts\" because colab already has a lot preinstalled with requirements different to ours\n",
"pip install --no-warn-conflicts \"colabfold[alphafold-minus-jax] @ git+https://github.com/sokrypton/ColabFold@dc9fc3d03379d23784e796f4c7fd31d173bafaa2\"\n",
"# high risk high gain\n",
"pip uninstall jaxlib -y\n",
"pip install \"jax[cuda11_cudnn805]==0.3.24\" jaxlib==0.3.24+cuda11.cudnn805 -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html\n",
"pip uninstall jax jaxlib -y\n",
"pip install \"jax[cuda]==0.3.25\" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html\n",
"touch COLABFOLD_READY\n",
"'''\n",
" run_shell_commands(cmds, 'install_colabfold.sh', install_log)\n",
Expand Down
4 changes: 2 additions & 2 deletions src/bundles/alphafold/src/alphafold_test_colab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@
"# We have to use \"--no-warn-conflicts\" because colab already has a lot preinstalled with requirements different to ours\n",
"pip install --no-warn-conflicts \"colabfold[alphafold-minus-jax] @ git+https://github.com/sokrypton/ColabFold@dc9fc3d03379d23784e796f4c7fd31d173bafaa2\"\n",
"# high risk high gain\n",
"pip uninstall jaxlib -y\n",
"pip install \"jax[cuda11_cudnn805]==0.3.24\" jaxlib==0.3.24+cuda11.cudnn805 -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html\n",
"pip uninstall jax jaxlib -y\n",
"pip install \"jax[cuda]==0.3.25\" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html\n",
"touch COLABFOLD_READY\n",
"'''\n",
" run_shell_commands(cmds, 'install_colabfold.sh', install_log)\n",
Expand Down
4 changes: 2 additions & 2 deletions src/bundles/alphafold/src/colabfold_predict.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@
"# We have to use \"--no-warn-conflicts\" because colab already has a lot preinstalled with requirements different to ours\n",
"pip install --no-warn-conflicts \"colabfold[alphafold-minus-jax] @ git+https://github.com/sokrypton/ColabFold@dc9fc3d03379d23784e796f4c7fd31d173bafaa2\"\n",
"# high risk high gain\n",
"pip uninstall jaxlib -y\n",
"pip install \"jax[cuda11_cudnn805]==0.3.24\" jaxlib==0.3.24+cuda11.cudnn805 -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html\n",
"pip uninstall jax jaxlib -y\n",
"pip install \"jax[cuda]==0.3.25\" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html\n",
"touch COLABFOLD_READY\n",
"'''\n",
" run_shell_commands(cmds, 'install_colabfold.sh', install_log)\n",
Expand Down
4 changes: 2 additions & 2 deletions src/bundles/alphafold/src/colabfold_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ def install(use_amber = False, use_templates = False, install_log = 'install_log
# We have to use "--no-warn-conflicts" because colab already has a lot preinstalled with requirements different to ours
pip install --no-warn-conflicts "colabfold[alphafold-minus-jax] @ git+https://github.com/sokrypton/ColabFold@dc9fc3d03379d23784e796f4c7fd31d173bafaa2"
# high risk high gain
pip uninstall jaxlib -y
pip install "jax[cuda11_cudnn805]==0.3.24" jaxlib==0.3.24+cuda11.cudnn805 -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
pip uninstall jax jaxlib -y
pip install "jax[cuda]==0.3.25" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
touch COLABFOLD_READY
'''
run_shell_commands(cmds, 'install_colabfold.sh', install_log)
Expand Down
2 changes: 1 addition & 1 deletion src/bundles/atom_search/bundle_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<Dependencies>
<Dependency name="ChimeraX-Core" version="~=1.0"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=11.0"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=12.0"/>
</Dependencies>

<Classifiers>
Expand Down
2 changes: 1 addition & 1 deletion src/bundles/atomic/bundle_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<!-- Edit bundle_info.xml.in, not bundle_info.xml; then run make_selectors.py -->
<Dependencies>
<Dependency name="ChimeraX-Core" version="~=1.0"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=11.0"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=12.0"/>
<Dependency name="ChimeraX-ConnectStructure" version="~=2.0"/>
<Dependency name="ChimeraX-Geometry" build="true" version="~=1.0"/>
<Dependency name="ChimeraX-Graphics" build="true" version="~=1.0"/>
Expand Down
2 changes: 1 addition & 1 deletion src/bundles/atomic/bundle_info.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<!-- Edit bundle_info.xml.in, not bundle_info.xml; then run make_selectors.py -->
<Dependencies>
<Dependency name="ChimeraX-Core" version="~=1.0"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=11.0"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=12.0"/>
<Dependency name="ChimeraX-ConnectStructure" version="~=2.0"/>
<Dependency name="ChimeraX-Geometry" build="true" version="~=1.0"/>
<Dependency name="ChimeraX-Graphics" build="true" version="~=1.0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,17 @@ AtomicStructure::normalize_ss_ids()
}

void
AtomicStructure::make_chains() const
AtomicStructure::_make_chains() const
{
if (_chains != nullptr) {
for (auto c: *_chains)
delete c;
delete _chains;
std::set<ChainID> pre_existing;
if (_chains == nullptr) {
_chains = new Chains();
} else {
for (auto chain: *_chains)
pre_existing.insert(chain->chain_id());
}
_chains_made = true; // prevent resursion

_chains = new Chains();
auto polys = polymers();

// In an ideal world there would be a one-to-one correspondence between
Expand All @@ -321,6 +323,8 @@ AtomicStructure::make_chains() const
for (auto key_polys: id_to_polys) {
auto id_type = key_polys.first;
auto chain_id = id_type.first;
if (pre_existing.find(chain_id) != pre_existing.end())
continue;
auto pt_type = id_type.second;
auto& chain_polys = key_polys.second;
std::vector<Residue*> res_list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ namespace atomstruct {

class ATOMSTRUCT_IMEX AtomicStructure: public Structure {
friend class Atom; // for IDATM stuff and structure categories
friend class Bond; // for checking if make_chains() has been run yet, struct categories
friend class Bond; // struct categories
friend class Residue; // for _polymers_computed
friend class StructureSeq; // for remove_chain()
private:
void _compute_atom_types();
void _compute_structure_cats() const;
void _make_chains() const;
public:
AtomicStructure(PyObject* logger = nullptr) : Structure(logger) {}

void compute_secondary_structure(float energy_cutoff = -0.5, int min_helix_length = 3,
int min_strand_length = 3, bool = false, CompSSInfo* = nullptr);
AtomicStructure* copy() const;
void make_chains() const;
void normalize_ss_ids();
std::vector<std::pair<Chain::Residues,PolymerType>> polymers(
PolymerMissingStructure missing_structure_treatment = PMS_ALWAYS_CONNECTS,
Expand Down
17 changes: 6 additions & 11 deletions src/bundles/atomic_lib/atomic_cpp/atomstruct_cpp/Structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,10 +883,10 @@ Structure::_delete_atoms(const std::set<Atom*>& atoms, bool verify)
void
Structure::_form_chain_check(Atom* a1, Atom* a2, Bond* b)
{
// If initial construction is over (i.e. Python instance exists) and make_chains()
// has been called (i.e. _chains is not null), then need to check if new bond
// If initial construction is over (i.e. Python instance exists) and _make_chains()
// has been called (i.e. _chain_made is true), then need to check if new bond
// or missing-structure pseudobond creates a chain or coalesces chain fragments
if (_chains == nullptr)
if (!_chains_made)
return;
auto inst = py_instance(false);
Py_DECREF(inst);
Expand Down Expand Up @@ -1134,16 +1134,11 @@ Structure::find_residue(const ChainID& chain_id, int num, char insert, ResName&
}

void
Structure::make_chains() const
Structure::_make_chains() const
{
// since Graphs don't have sequences, they don't have chains
if (_chains != nullptr) {
for (auto c: *_chains)
delete c;
delete _chains;
}

// since non-atomic Structures don't have sequences, they don't have chains
_chains = new Chains();
_chains_made = true;
}

Atom *
Expand Down
5 changes: 3 additions & 2 deletions src/bundles/atomic_lib/atomic_cpp/atomstruct_cpp/Structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class ATOMSTRUCT_IMEX Structure: public GraphicsChanges,
float _ball_scale = 0.25;
Bonds _bonds;
mutable Chains* _chains;
mutable bool _chains_made = false;
ChangeTracker* _change_tracker;
CoordSets _coord_sets;
bool _display = true;
Expand Down Expand Up @@ -202,6 +203,7 @@ class ATOMSTRUCT_IMEX Structure: public GraphicsChanges,
std::set<Atom*>& left_missing_structure_atoms,
std::set<Atom*>& right_missing_structure_atoms,
const std::set<Atom*>* deleted_atoms = nullptr) const;
virtual void _make_chains() const;
Bond* _new_bond(Atom* a1, Atom* a2, bool bond_only);
Chain* _new_chain(const ChainID& chain_id, PolymerType pt = PT_NONE) const {
auto chain = new Chain(chain_id, const_cast<Structure*>(this), pt);
Expand Down Expand Up @@ -243,7 +245,7 @@ class ATOMSTRUCT_IMEX Structure: public GraphicsChanges,
void bonded_groups(std::vector<std::vector<Atom*>>* groups,
bool consider_missing_structure) const;
const Bonds& bonds() const { return _bonds; }
const Chains& chains() const { if (_chains == nullptr) make_chains(); return *_chains; }
const Chains& chains() const { if (!_chains_made) _make_chains(); return *_chains; }
void change_chain_ids(const std::vector<StructureSeq*>, const std::vector<ChainID>,
bool /*non-polymeric*/=true);
ChangeTracker* change_tracker() { return _change_tracker; }
Expand Down Expand Up @@ -276,7 +278,6 @@ class ATOMSTRUCT_IMEX Structure: public GraphicsChanges,
bool is_traj;
PyObject* logger() const { return _logger; }
bool lower_case_chains;
virtual void make_chains() const;
std::map<std::string, std::vector<std::string>> metadata;
Atom* new_atom(const char* name, const Element& e);
Bond* new_bond(Atom* a1, Atom* a2) { return _new_bond(a1, a2, false); }
Expand Down
2 changes: 1 addition & 1 deletion src/bundles/atomic_lib/bundle_info.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<BundleInfo name="ChimeraX-AtomicLibrary" version="11.0"
<BundleInfo name="ChimeraX-AtomicLibrary" version="12.0"
package="chimerax.atomic_lib"
purePython="false"
installedDataDir="data"
Expand Down
2 changes: 1 addition & 1 deletion src/bundles/chem_group/bundle_info.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Dependency name="ChimeraX-Core" version="~=1.0"/>
<Dependency name="ChimeraX-Arrays" build="true" version="~=1.0"/>
<Dependency name="ChimeraX-Atomic" version="~=1.0"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=11.0"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=12.0"/>
</Dependencies>

<Classifiers>
Expand Down
2 changes: 1 addition & 1 deletion src/bundles/connect_structure/bundle_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<Dependencies>
<Dependency name="ChimeraX-Core" version="~=1.0"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=11.0"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=12.0"/>
</Dependencies>

<Classifiers>
Expand Down
4 changes: 2 additions & 2 deletions src/bundles/core/src/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,8 @@ def init(argv, event_loop=True):
import runpy
import warnings
exit = SystemExit(os.EX_OK)
from chimerax.core.python_utils import chimerax_user_base
with warnings.catch_warnings(), chimerax_user_base():
from chimerax.core.python_utils import chimerax_environment
with warnings.catch_warnings(), chimerax_environment():
warnings.filterwarnings("ignore", category=BytesWarning)
global_dict = {
'session': sess
Expand Down
63 changes: 49 additions & 14 deletions src/bundles/core/src/python_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,57 @@ def chimerax_python_executable():


@contextmanager
def chimerax_user_base():
"""Make pip install packages to ChimeraX's customary PYTHONUSERBASE.
def chimerax_environment():
"""Setup environment for Python to match ChimeraX setup
Without this context manager, Python will install packages in the traditional
user directory at, on macOS, ~/Library/Python/(version)/lib/python/site-packages
instead of our location at ~/Library/Application Support/ChimeraX/(cx_version)
In particular, set PYTHONUSERBASE so pip will install/uninstall packages
in the ChimeraX "user" location. Also remove from environment any
variables that would alter ChimeraX's behaviour.
"""
from chimerax import app_dirs
old_pythonuserbase = os.environ.get('PYTHONUSERBASE', None)
os.environ['PYTHONUSERBASE'] = app_dirs.user_data_dir
PROTECT = {
'PYTHONDONTWRITEBYTECODE': None,
# 'PYTHONDEBUG': None,
# 'PYTHONINSPECT': None,
# 'PYTHONOPTIMIZE': None,
'PYTHONNOUSERSITE': None,
# 'PYTHONUNBUFFERED': None,
# 'PYTHONVERBOSE': None,
# 'PYTHONWARNINGS': None,
'PYTHONSTARTUP': None,
'PYTHONPATH': None,
'PYTHONHOME': None,
'PYTHONPLATLIBDIR': None,
'PYTHONCASEOK': None,
'PYTHONUTF8': None,
'PYTHONIOENCODING': None,
'PYTHONFAULTHANDLER': None,
# 'PYTHONHASHSEED': None,
'PYTHONINTMAXSTRDIGITS': None,
# 'PYTHONMALLOC': None,
'PYTHONCOERCECLOCALE': None,
# 'PYTHONBREAKPOINT': None,
# 'PYTHONDEVMODE': None,
'PYTHONPYCACHEPREFIX': None,
'PYTHONWARNDEFAULTENCODING': None,
'PYTHONUSERBASE': app_dirs.user_data_dir,
}
old_environ = {}
for var, new_value in PROTECT.items():
old_value = os.environ.get(var, None)
if old_value is None and new_value is None:
continue
old_environ[var] = old_value
if new_value is None:
del os.environ[var]
else:
os.environ[var] = new_value
yield
if old_pythonuserbase is None:
del os.environ['PYTHONUSERBASE']
else:
os.environ['PYTHONUSERBASE'] = old_pythonuserbase
for var, value in old_environ.items():
if value is None:
del os.environ[var]
else:
os.environ[var] = value


def is_link(path):
Expand Down Expand Up @@ -83,10 +119,9 @@ def run_pip(command):
# the user site directory is the ChimeraX application location.
import subprocess
prog = chimerax_python_executable()
pip_cmd = [prog] + subprocess._args_from_interpreter_flags() + ["-m", "pip"]
pip_cmd = [prog] + ["-m", "pip"]
# pip_cmd = [sys.executable, "-m", "pip"]
from chimerax.core.python_utils import chimerax_user_base
with chimerax_user_base():
with chimerax_environment():
cp = subprocess.run(pip_cmd + command, capture_output=True)
return cp

Expand Down
8 changes: 3 additions & 5 deletions src/bundles/core/src/scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ def probably_chimera1_session(evalue):
return False

chimera1_session_message = """\
ChimeraX cannot open a regular Chimera session. An exporter from Chimera
to ChimeraX is being worked on but only handles molecules and molecular surfaces
(not volumes) at this time. If that is sufficient, use the latest Chimera
daily build and its File->Export Scene menu item, and change the resulting
dialog's "File Type" to ChimeraX."""
ChimeraX cannot open a regular Chimera session. An exporter from Chimera to
ChimeraX is available in the latest Chimera release. Use its File->Export Scene
menu item, and change the resulting dialog's "File Type" to ChimeraX."""
2 changes: 1 addition & 1 deletion src/bundles/dssp/bundle_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<Dependencies>
<Dependency name="ChimeraX-Core" version="~=1.0"/>
<Dependency name="ChimeraX-Arrays" build="true" version="~=1.0"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=11.0"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=12.0"/>
</Dependencies>

<Classifiers>
Expand Down
2 changes: 1 addition & 1 deletion src/bundles/mmcif/bundle_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<Dependency name="ChimeraX-Core" version="~=1.0"/>
<Dependency name="ChimeraX-Arrays" build="true" version="~=1.0"/>
<Dependency name="ChimeraX-Atomic" version="~=1.34"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=11.0"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=12.0"/>
<Dependency name="ChimeraX-PDB" version="~=2.0"/>
<Dependency name="ChimeraX-PDBLibrary" build="true" version="~=1.0"/>
<Dependency name="ChimeraX-DataFormats" version="~=1.0"/>
Expand Down
2 changes: 1 addition & 1 deletion src/bundles/mmtf/bundle_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<Dependency name="ChimeraX-Core" version="~=1.0"/>
<Dependency name="ChimeraX-Arrays" build="true" version="~=1.0"/>
<Dependency name="ChimeraX-Atomic" version="~=1.0"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=11.0"/>
<Dependency name="ChimeraX-AtomicLibrary" build="true" version="~=12.0"/>
<Dependency name="ChimeraX-PDB" version="~=2.0"/>
<Dependency name="ChimeraX-PDBLibrary" build="true" version="~=1.0"/>
<Dependency name="ChimeraX-DataFormats" version="~=1.0"/>
Expand Down
Loading

0 comments on commit 5d3df79

Please sign in to comment.