mdanalysis | Python library to analyze molecular dynamics simulations
kandi X-RAY | mdanalysis Summary
kandi X-RAY | mdanalysis Summary
MDAnalysis is a Python library to analyze molecular dynamics simulations.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Compute the residuals for each ensemble
- Run the function
- Calculate bootstrapping samples for a given distance matrix
- Join a sequence
- Estimate the clustering for the given ensemble
- Cluster multiple ensembles
- Compute similarity between two ensemble members
- Discrete Jensen - Shannon divergence
- Decorator to check that a function is valid
- Perform ensemble clustering
- Extract a HOLE profile
- Convert a fasta file into protein sequences
- Generate extension
- Parse the file
- Parse the molecule
- Generate streamlines for a 3D trajectory
- Run a single frame
- Parse mol2 file
- Parse the ATOM lines into a dictionary
- Parse the gmx top file
- Write an object to a file
- Parse the ATOM file
- Generate streamlines
- Write a trajectory to a file
- Run the simulation
- Parse the SQLite3 database
mdanalysis Key Features
mdanalysis Examples and Code Snippets
Community Discussions
Trending Discussions on mdanalysis
QUESTION
I'm in a bit unusual situation. There are seven different proteins stored in a single file according to their residues names. Each protein has different sequence length. Now I need to calculate the center of mass of each protein and generate a time series data.I know how to do with a single protein, but do not with multiple protein system. For single protein I can do something like this:
...ANSWER
Answered 2022-Mar-01 at 15:49I would load the system from the TPR file to maintain the bond information. Then MDAnalysis can determine fragments (namely, your proteins). Then loop over the fragments to determine the COM time series:
QUESTION
I have some working code using MDAnalysis that saves the residues center of mass time series in an array, but I wonder if there is a more Pythonic or overall efficient/fast way (comprehensions, array operations...) to do it.
...ANSWER
Answered 2022-Jan-19 at 14:57There are a couple of changes you could make to your code:
- select your protein atoms outside of the for loop, rather than on each iteration
- vectorise the center of mass calculation over residues by passing the
compound='residues'
argument to thecenter_of_mass
method - use the
ag.n_residues
andu.trajectory.n_frames
attributes
Here's an update to your code that uses these suggestions:
QUESTION
I'm trying to create a dictionary and my dictionary keys keep overwriting themselves. I don't understand how I can handle this issue.
Here's the script:
...ANSWER
Answered 2021-Dec-13 at 19:55Without actually seeing a complete problem description, my guess is that your final result is that each charge_dict[name]
is a dictionary with just one key. That's not because the keys "overwrite themselves". Your program overwrites them explicitly: charge_dict[resnames[i]] = {}
.
What you want is to only reset the value for that key if it is not already set. You could easily do that by first testing if resnames[i] not in charge_dict:
, but the Python standard library provides an even simpler mechanism: collections.defaultdict
. A defaultdict
is a dictionary with an associated default value creator. So you can do the following:
QUESTION
I have a pdb file that is a subset of a much larger system. This pdb is special because I have some vectors based on this file's coordinate system. I want to draw these vectors and the basis vector of that system onto the pdb. Eventually I would like to visualize the vector and basis vectors as it moves through some MD simulation where I an update the vector position based on the trajectory over time.
To start, I would like to read a pdb that has coordinates that define the basis vectors that further define the other vectors I want to visualize. Right now I'm using this class in MDAnalysis: https://docs.mdanalysis.org/1.0.0/_modules/MDAnalysis/coordinates/PDB.html#PDBReader
...ANSWER
Answered 2021-Mar-17 at 05:48Universe
To get the coordinates in MDAnalysis you first load a Universe (you don't normally use the coordinate readers directly):
QUESTION
I'm trying to install and import MDAnalysis and MDAnalysisTests libraries on Google Colaboratory, I've tried three ways but nothing works:
- Using default: !pip install library
ANSWER
Answered 2021-Mar-13 at 13:06You can use conda to install MDA in Colab (takes a while).
QUESTION
I am running a simple benzene simulation in GROMOS54a7. I want to calculate the RDF of the center of masses of each benzene molecule, using MDAnalysis 1.0.0.
Is this possible? I have create the rdf for the C molecules g_cc(r) using the following code in a Jupyter Notebook:
...ANSWER
Answered 2021-Feb-24 at 10:47It would be useful to make it possible to use CG groups as native atoms in order to reuse the analysis tools in MDAnalysis.
Here is a quick fix that mimics the MDAnalysis group and presents a new positions
property. The new positions
provides the centre of geometry instead of the actual positions. I also overwrite the len to convey that only one bead is being used for the CG element.
QUESTION
I would like to know whether it is possible, and how, to host a Jupyter Notebook page somewhere remotely (so not on my machine) that a collaborator could load in their web browser to view results? There is no shared machine, all the files need to be in one central location e.g., hosted on Google Drive, and the Jupyter Notebook page must also be URL based accessible.
First of all, I've performed MD simulations using Gromacs and the files are currently local on my machine. I then load Jupyter Notebook on my machine, import the MDAnalysis Python package and perform some analysis that depends on those trajectory files generated by Gromacs (.trr/.xtc/.pdb). I also include some short simulation trajectories using NGLViewer so I can observe the parts of a simulation.
The problem I face is that I want my collaborator to see/interact with the analysis work and observe the simulations using NGLViewer.
There are a few challenges involved:
(1) How/where do I host a Jupyter Notebook remotely so my collaborator can view progress in a browser window? I'm not expecting them to make edits or run code, just observe and copy text and download figures. This is to save me from packaging (e.g., as a markdown document of some kind) incremental versions of analysis and emailing them over.
(2) What is required for analysis code (written in Python and using the MDAnalysis package) in this remote Jupyter Notebook page to load data files that are stored remotely on e.g., Google Drive?
(3) Similar to (2), can NGLViewer load a remote file e.g., stored on Google Drive, and display the trajectory on the site for the collaborator to observe?
Although my question ties in python packages such as MDAnalysis, NGLViewer and the results from a third party application (Gromacs), I'm looking for a new way sharing results from multiple projects to teams in different countries, along with my own team who I can't meet in person at the moment.
...ANSWER
Answered 2021-Jan-27 at 11:43You can create a Google Drive folder and add the data to it. Then share the data with all your colleagues that need to access the data.
Finally, create a Google Colab notebook and add the code there. You can choose to allow people to edit and run the notebook or only allow them to see the results. If you only give them read permission, they will have to save a copy from the notebook into their own google drive to be allowed to edit the notebook.
These options are all available in the menu bar from Colab.
You can connect your google drive folder to Colab as follows:
QUESTION
I got this script for generating time series data of water molecules, and I want to add one more header row to that generated matrix with residue IDs of water molecules. Could anybody help with with reworking this script? Thanks!
...ANSWER
Answered 2020-Jul-08 at 11:02Here is an adjusted code example. You might need to install the package MDAnalysisTests
to run it:
QUESTION
I do RMSF analysis and as a results I have list of floats (0.1, 0.3, etc.) and I would like to do a histogram where are bins of defined ranges of the floats. Then I want to have each range of float with corresponding color. I tried to do it with analogies of this script:
...ANSWER
Answered 2020-Apr-27 at 18:12IIUC, you would want to pass bins
into ax.hist
:
QUESTION
I am trying to make a file which contain time series data of water molecules from dcd file. Is it possible to generate this data using any of MDAnalysis module or function? Or is there any python script to generate this file?
I need to generate this file containing two columns (one with z coordinates of water molecules and 2nd with respective timesteps) by using DCD file as input.
...ANSWER
Answered 2020-Mar-04 at 23:16You can get the (z, t) time series in a variety of ways but I am showing the most basic one here. I assume that you also have a PSF topology file in addition to your DCD trajectory file (but really, any topology and trajectory file format will work in MDAnalysis). I also assume that the water oxygen atoms are named "OW".
I am actually not clear how you want your "z, t" data structure to look like. If you have N
water molecules, then you will have N
z-coordinates per time step so I don't know how this makes sense as "two columns", assuming that you want each "row" to be a different time step. Instead I will use the following data structure: the final output will be an array with shape (T, N+1)
where T
is the number of time steps in the trajectory and N
is the number of waters. Each row of the array contains [t, z1, z2, ..., zN]
, i.e., time and z-coordinate of water i.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install mdanalysis
You can use mdanalysis like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page