Open attentionbydesign opened 2 weeks ago
Interestingly, the standard accelerator 'op' that opens the "Open File in Chimera" dialog is defined as such
def open_file(): 'Show the main Chimera open file dialog' import chimera.tkgui chimera.tkgui._importModel()
So it looks like the key method here is
chimera.openModels.open('path/to/file')
which seems to be the only code that would open anything within the openPath() method of the chimera.tkgui module.
the Apply() method of of the _ImportDialog class in tkgui ends with a loop that applies openPath() over what seems like all the selected files in the Open File dialog
_ImportDialog is what is returned by the importDialog() function in tkgui
and _importModel() simply calls importDialog().enter()
and that takes us back to the beginning pretty much.
Unfortunately, openModels is really just a python alias for _chimera.OpenModels, meaning I can't see the source code, I don't think...
for now,
chimera.openModels.open('path/to/file.ext', openAs = 'filetype')
turned out to be the appropriate syntax, with 'filetype' = 'PDB'
.
Remaining Issues for PDB Clean/Write:
PDBWriter
[ ] Make sure default save location is the same as at least one of the substituent PDBs. In the case of PDBs from different locations, prioritize the most common (e.g., if two of three substituent PDBs are from directory1/ while one is from directory2/ then save the merged file in directory 1/; if only two substituents? Maybe should just have a default location for saving merged PDBs, and/or create a dialog to set the output directory)
[ ] Create output/save directory dialog
[ ] Better default naming convention for the merged file? Considering the fact that the substituent mols might have really long names, bad idea to concatenate them whole; maybe find a way to automate abbreviate, like selecting on the first N characters; currently using concat of MID's and then adding date & time to make each file unique
[ ] still needs import from PDBclean and to be cleaned up after being joined; perhaps could write more deeper level code than simply using Midas module and avoid creating unwanted lines altogether; i.e., figure out your own algo for deciding the order of side chains to write into the file, writing the data directly into a text file and naming it with pdb extension. The purpose is not to include all of the fancy headers etc. for submission as we're still in modeling phase
PDBClean
[ ] code elegance: can be more efficient by filtering IN instead of OUT i.e., look for lines that you want, such as ATOM, TER, and END.
[ ] filter options: are there situations where you might want to keep certain lines?
[ ] save options: default is currently to create a copy; might want an option to overwrite later on if you like how it turned out
[ ] solution for special atoms, including those of bulky side chains; this is mainly for compatibility with SPIDER, as hydrogens with > 1-digit numbering can make it seem like it's part of the next field. Perhaps deleting hydrogens by default is enough, since chimera has the option to add them back fairly easily. In which case you might just use chimera's source code for their delete hydrogens function... or start there for inspiration.
[ ] once CID_Manager module written, can reallocate chain ID's and atom numbering after merging different parts of different PDB files... i.e.,
resolve same chain ID conflicts
reorder chain IDs in a more linear fashion,
make sure atoms of chains in alphabetical order inside the actual text file!
started working on pdbjoin() within the pdbwriter module of PDB_Manager