Confused with psfgen module of VMD - protein-database

I am fairly new to VMD and programming in general.
I need to combine two pdb files of subunits into a combined pdb and psf file with both subunits.
I used the Namd tutorial and used two pdb files named BChain270VerCTrue.pdb and barn_noH2o_ChainD.pdb and ran this pgn in VMD:
package require psfgen
topology top_all27_prot_lipid.inp
pdbalias residue HIS HSE
pdbalias atom ILE CD1 CD
segment A {pdb BChain270VerCTrue.pdb}
segment D {pdb barn_noH2o_ChainD.pdb}
coordpdb BChain270VerCTrue.pdb A
coordpdb barn_noH2o_ChainD.pdb D
guesscoord
writepdb BarnaseBarnstar270True.pdb
writepsf BarnaseBarnstar270True.psf
However, this creates a sort of mangled pdb that has both subunits covalently bonded. How could I fix this?
This is how the two pdb files look when just used separately in VMD:
This is what the code spits out:

Barnase and barstar are the extracellular ribonuclease and its intracellular inhibitor produced by Bacillus amyloliquefaciens. These two proteins have strong binding energy therefore frequently used for studying protein-protein interaction. To simulate this interaction in silico, We need a proper 1) Forced field, 2) Topology files, and 3) Molecular Dynamic packages like NAMD, Gromacs, or Amber. Plus little bitty understanding of the PDB file format and Structural Biology, and Python or Bash scripting skills.
To generate a topology file one has to generate each component separately, if PDB file has two chains then one has to separate them. However, when we have to put them back we have to follow PDB file format rules. (details can be found at https://www.wwpdb.org/documentation/file-format).
PDB format is composed of many columns but the first column contains the atom information like ATOM, HETATOM, or TER. The last TER designates termination of one chain, without it some software considers them as a single chain like your case.
Make sure two chains are separated TER. you can use a simple text editor to put.

Related

How do I write a macro in Stata to identify the file with most recent date in title?

I am working with a set of .dta files in Stata, each of which takes some time to create and each of which contains the date of creation in the file name (created at the point of saving using a macro with today's date).
At the moment my do-files identify the relevant .dta file to open based on the today's date macro, but this requires that I run the code to create the .dta files each day.
Is there a way of asking Stata to identify the most recently dated file from a set of files with same filename stem and different dates within a folder (and then open it), once I have run the "cd" command? I had a look on Statalist and SO but couldn't see an answer - any advice gratefully received.
e.g. In the folder, I have files 2020-08-23_datasetA.dta, 2020-08-22_datasetA.dta, 2020-08-22_datasetB.dta etc, and at different points I will want to select the most recently-dated version of A, B, C etc. Hence don't think a simple sort will work as there are datasets A, B, C at play.
(My question is essentially the Stata version of this one about R - Loading files with the most recent date in R)
[edited to clarify that there are multiple datasets, each of which is dated and each of which will need to be opened at different points]
Manifestly two or more files in a particular folder can't have the same name. But we know what you mean.
A utility like fs from SSC will return a list of filenames matching a pattern, alphanumerically sorted. With your dating convention the last named will be the latest as your dates follow (year, month, day) order.
Using another convention for the rest of the filename won't undermine that, but naturally you need to spell out which subset of files is of interest. So a pattern is
. ssc install fs
. fs *datasetA.dta
. local wanted = word(r(files), -1)
where the installation need only take place once. You can circumvent fs by using the calls to official Stata that it uses.
Perhaps you are seeking a program, but it's not clear to me that you need one.
Small detail: You're using the word macro in a way that doesn't match its Stata sense. Stata, for example, is not SAS! The terms code, routine and script are generic and don't conflict with any Stata use. Conversely, code, routine or script may have fixed meanings in other software you use. Either way, Stata questions are best phrased using Stata terms.

Add the hash of the code in executable file

I have an STM32 application which uses two blocks of memory. In 0th block, I have a boot code (which runs just after power-on) and in 7th block, I have an application code (which may or may not run depending on the authorization decision given by the boot code).
Those two codes are developed hence generated by two separate projects. They are flashed on the specific blocks (boot code to 0th block and application code to 7th block) of STM32 NOR memory using openocd tool by giving an offset value to the openocd's write_image command.
What I would like to do basically in the boot code is that I want to calculate the hash of the application code and compare it with the reference digest. If they are equal, I will give the hand to the application code. For that, after I generate the executable (can be in elf, hex or bin format) of the application code, I want to:
Create another file (in any format listed above) which has 128K byte size
Copy the content of the executable file to the recently created file from its beginning (0 offset)
Write the hash of the executable to the last 32 bytes of the recently created file
Fill the gap with 0xFF
Finally flash this executable file (if it is still) to the 7th block of the memory
Do you think that it is doable and feasible? If so:
Which format should I use to generate the executable?
Do I have something that I need to give specific attention to achieve this?
Lastly, do you think that it makes sense to do that or is there any other more standard way for this purpose?
Thanks a lot in advance.
You just need to add an additional step to your building sequence. After the linking extract the binary file from elf
Then write a program in your favourite programming language which will calculate something and append the result to that bin file

Two closely matching files: get corresponding lines?

I'm in a situation where I'm programmatically generating LaTeX code, and I want my Synctex to point to the correct lines in the original file.
The generation is basically doing template expansion, so the original files are nearly identical to the generated ones, but with some snippets expanded.
I'm wondering, is there a diff tool or library that will easily give me the line number of the original file that corresponds to a given line in the generated one? Can this be extracted from a normal Unix diff somehow?
This is part of a build script, so ideally something easy to run, like bash or python, is preferred to something that needs to be compiled.
Google’s diff-match-patch lib is a neat solution to questions like these: https://github.com/google/diff-match-patch

How to produce a consolidated source file?

Does MATLAB have the following capability: take source code that directly includes other .m files and output the source that would result from merging all included files?
For example, consider script_one.m:
% some matlab code
script_two
% more matlab code
I would like to programmatically generate the .m file that would result from copying and pasting the contents of script_two.m into script_one.m. This is difficult to do with normal scripting tools because I would essentially need a MATLAB symbol table to determine which identifiers correspond to sourceable scripts. I highly doubt that Matlab provides such a facility, but am open to other ideas.
The "use case" is the need to modify the source (using sed) but the changes need to propagated to any dependent scripts, such as script_two.m. As I don't have a listing of the dependent scripts, they can only be identified by going through the source manually (and it needs to be done on a large number of dynamically created files).
Some details on the use case:
The main script (script_one) is called with dynamically created header files, e.g., matlab [args] -r 'some definitions; script_two; script_three; others; main_script();quit()'. This is run on machine A; for load balancing, it may need to be run instead on machines B, C, etc, which mount the file system of A at some point. Any paths in the included .m files (which are mainly used as headers) would need to be essentially chrooted to work on the new host. The simplest solution would be to preprocess the code which was generated for machine A, using sed to replace all paths for the new host (B, C, etc.). It can of course be solved by making the changes in matlab, but a sed one-liner is a more attractive solution in terms of parsimony.
In general, no, it's not possible in MATLAB. What you want is a language feature common to languages that require compilation step before execution, but this is not MATLAB's language model, and therefore, it is only doable via hacky wacky language abuse.
You could, conceivably, create a master script, which takes care of coordinating the generation of new source files, and executing them via eval():
[o,e] = system('<your sed command here, to generate script_one.m>');
% ... some more code
% execute newly generated M-file
[outputs] = eval('script_one');
But I hope you see and agree that this turns into spaghetti really quickly.
Executing a script with changing contexts and parameters is exactly what the function language feature was invented for :)

Generate executable larger than 4GB with TurboStudio

Thinapp has no problem generating virtual applications above 4GB.
Whenever I try something similar with TurboStudio it fails. Is there a way around it?
Okay, after several experiments I think I found an answer.
Spoon Studio (or Turbo Studio as it is now called) cannot create executables larger than 4GB. Checking the "Compress Payload" option reduces output size, but these captures perform usually a bit slower (due to the decompression required at runtime) and of course, there are always apps that will exceed the 4GB limit even with this option checked.
A workaround, however, is to divide the installation process in multiple captures (when possible) and use svm files.
For example, assume you are capturing a large application (Myapp) and some addons or plugins to it which together generate a capture larger than 4GB in size.
The solution would then be to first capture the application without any addons. Then install the plugins/addons and capture them separately. When you capture the plugins choose as Project Type "Component". At the end of this process you will have a captured application in executable "myapp.exe" and the plugins captured separately in "plugins.svm". It is possible to repeat this process several times, thus ending with "myapp.exe" and multiple SVMs, such as "plugins.svm", "plugins02.svm" etc.
In order to load the "plugins.svm" in "myapp.exe" without importing it as a component (which would defeat the purpose as it would still blow up the size beyond 4GB), go to Settings-->Process Configuration-->SVMs.
In the SVM search pattern you enter a text string to specify the SVMs to be loaded during startup of the application.
You can specify a single SVM by entering something like
#APPDIR#\plugins.svm
or multiple SMVs by entering something like
#APPDIR#\plugins.svm;#APPDIR#\plugins02.svm
or even use a wildcard by entering something like
#APPDIR#\*.svm
All of the above examples imply that the desired SVMs exist in the application's folder. Else, use a different path.
If multiple SVMs are specified in one search pattern through the use of the '*' wildcard, the SVMs are applied in reverse-alphabetical priority.
If SVMs are specified by name (not with a wildcard), then the SVMs specified first in the list will take precedence over SVMs specified later in the list.
You can also make specific svm files Required, by adding them to the "Required SVM name" list. In this case, the application won't start if it doesn't find the SVM file in the specified location and will instead give an error message that a required SVM was not located.
I hope this will be of help to people trying to capture large applications and hitting the 4GB limit with Turbo (Spoon) Studio.