Focusing in on specific areas in PyMOL from command line? - pymol

I just started using PyMOL and Unix commands to look at .pdb files and I have a task that I want to perform, but I don't know exactly how to implement it.
You can find the task described below:
"Download this tar file and unpack it using the command line.
This file contains 271 .pdb files and I want to focus in on residues numbered 40-55 in all files using PyMOL from the command line.
Once those residues are focused in PyMOL, I want to save the images and export the snapshots to an html page/format."
I would like to do all this using piping in Unix. I have some of the basics down but I need help with some of the more complex tasks. Any help is greatly appreciated!

Since you want to do this using "piping in Unix", I will describe here the plain command line version on how to proceed. I will deliberately omit the part "export the snapshots to an html page/format" because this goes beyond PyMOL and can be done with many other programs or tools.
First, you want to iterate over the pdb files inside your folder:
for protein in *.pdb;
###launching PyMOL and passing commands here;
done
these commands you are going to need for PyMOL:
First, let's start the PyMOL executable from the shell. Depending on the operating system you work on this may vary. I will use macOS as an example. Further help on how to start PyMOL from the command line you can find here.
/Applications/PyMOL.app/Contents/MacOS/PyMOL -cq $protein -d "###here come the PyMOL commands"
c means, that the PyMOL gui won't start (we don't need it here), and q omits PyMOL's welcome message. $protein is each PDB file we're looping over. d means PyMOL commands are going to be passed.
We are going to use the following commands to get your piece of peptide for each PDB file and create a PNG image:
first we make sure that nothing else will be visible:
hide everything;
now we select your residues 40 through 55 and name this selection "pieceofpeptide":
select pieceofpeptide, resi 40-55;
depending on how you want the representation to look (e.g. cartoon, licorice, lines etc.) you choose the style in the next command:
show cartoon, pieceofpeptide;
Now we make sure that the image is centered (try varying the number, it represents the distance from the object we center):
zoom center, 20;
Finally, let's save this as an image (adjust resolution to your needs):
png $protein.png, width=10cm, dpi=150, ray=1
written as a one-liner the final command eventually looks like this:
for protein in *.pdb; do /Applications/PyMOL.app/Contents/MacOS/PyMOL -cq $protein -d "hide everything;select pieceofpeptide, resi 40-55;show cartoon, pieceofpeptide;zoom center, 20;png $protein.png, width=10cm, dpi=150, ray=1"; done
It is however, much easier to see and edit if you store PyMOL commands in a file like script.pml, or use a Python script, but this is best explained here.

Related

Show nested folders in Total Commander

I know that default "CTRL+B" Windows command works for showing all nested files.
Is there a shortcut to show all nested folders?
I doubt if this feature exists in Total Commander. The built-in tree utility is always good enough for me.
If you don't like console output, just run this inside Total Commander's command line to copy the output to the clipboard:
tree | clip
Of course, you can assign it a shortcut. :)
Total Commander by version differs from the oldest one, if u can't find ur desired shortcut, just simply set this shortcut on the configuration panel as following:
>Start
>Change main menu
>Configuration
>Misc.
>Redefine Hotkeys...

How to add comments to folder in linux and view them with mouse cursor

I run simulations for various choices of parameters. For each choice I store the resulting data in a folder, like
/home/me/Documents/MyProject/C=10/1.dat
/home/me/Documents/MyProject/C=10/2.dat
/home/me/Documents/MyProject/C=10/3.dat
...
and
/home/me/Documents/MyProject/C=20/1.dat
/home/me/Documents/MyProject/C=20/2.dat
/home/me/Documents/MyProject/C=20/3.dat
...and so forth.
would like to write a little text file AAA.txt which contains not just the C parameter but all the others too. Then when viewing this folder which contains the data I want to hold my cursor on the little file symbol and have a little box appear. This box should show just the content of AAA.txt, so I can quickly check which set of parameters was used in this particular run.
Anyone know how to do this? I use Ubuntu 14.04
I am not aware of ways to give you a custom "tooltip". As an alternative, you could look into creating custom thumbnails of your .dat files.
See here for how to do that with nautilus; the default file browser for Ubuntu.
Alternatively, you might look into what Gloobus can do for you.

AppleScript Replace File

I'd like to write an AppleScript for replacing three system files with ones I've modified. I'd like to do this with an AppleScript instead of manually replacing them because I'll have to replace three files every time there's an OS X update. Specifically, I'll be replacing stock graphics drivers with ones I've modified to support a graphics card which is connected via Thunderbolt. Is it possible to write an AppleScript for replacing one file with another? I ask because I know that when you replace a file, a dialog pops up with three options, and I don't know how to address that.
You can do this with Finder:
set freshFile to choose file
tell application "Finder"
move freshFile to desktop replacing yes
end tell
All you need to do is work out the source and destination paths to completely automate the script.
Many scripters do not like working with Finder, for a variety of reasons. If you want something that is incredibly fast, you would use the do shell script inside of your AppleScript:
do shell script " mv -f ~/Desktop/ArlandaTilUppsala.pdf ~/Documents/Employ.pdf"

Append text file with custom footer

Good day,
I am a CNC program not a computer programer. I am using CAM software to make cutting programs for our CNC router. The router is a bit old and can only take files 200-300 kb big. We are doing carvings that require 1-2 megs text files. I am using a program called GSplit ( http://www.gdgsoft.com/gsplit/ ) to divvy up the text file. It generates 10-25+ files with a custom header that our machine can read. All the files are great and it works, but I have to manually add the closing lines/footer to each file. The files that are created and used are normal .txt files but with a specific extension, .ANC.
Is there any way to automate this process of opening each individual file, scrolling to the end and copy/pasting the same 1-2 lines of code? The files are NAME[number].ANC in a contained folder. Would it be possible to just direct to a folder and say "add this 'text' to every file in this folder"?
Thanks for your time.
What OS are you using? Using Unix you can do a simple script on command line. If you are in the directory with the specific files simply execute:
for file in *; do echo "APPEND THIS" >> $file; done
If you are running Windows you should be able to do the same using cygwin (probably you could also use the power shell, but I don't know anything about the that)
I found a program Notepad++ (apparently the last person to find it...). USed the find/replace files option. A regular expression(note sure exactly what these are but I'm sure you guys do) "\s+\z" as to what to look for. It finds the last space or whatever at the end of all the files and then adds the code I need. Easy, free, and I don't need to write any computer code. Thanks for the attempt to help me Dirkk! :)

Concatenating OpenDocument Text file in Linux from the command line

Is there a way to concatenate two OpenDocument Text documents (i.e. the format OpenOffice uses) in Linux from the command line? I'm looking for a command that will allow me to do something like:
concat-docs doc1.odt doc2.odt doc3.odt -o alldocs.odt
This hypothetical command would produce alldocs.odt, which would contain doc1, doc2, and doc3, one after the other.
I've already looked into doing this at the raw xml level, and it's rather complicated enough (renaming automatic styles to avoid conflicts etc.) that I'd prefer not to do it unless there aren't any other tools that will do what I want.
I am not able to double check right now, but you may want to check out some of the options available from the Python-UNO bridge or OOoPy. Both have utilities that sound like what you might want to do. Python-UNO bridge has something called oomerge.py that is described as "A command line tool, that creates a new document by appending multiple single documents", and OOoPy has a utility that is ooo_cat which is "for concatenating several OOo files into one".
Try these and post back with your findings....

Resources