### Check Python and NumPy Installation Source: https://github.com/tsjerk/insane/blob/master/README.md A simple Python command to verify if Python and the NumPy library are installed and accessible in the current environment. This is a prerequisite for installing and running Insane. ```python python -c 'import numpy' ``` -------------------------------- ### Setup Periodic Boundary Conditions (PBC) Source: https://context7.com/tsjerk/insane/llms.txt This Python code demonstrates the use of the `PBC` class from `insane.pbc` to set up periodic boundary conditions. It supports various box shapes like hexagonal, rectangular, and rhombic dodecahedral, allowing customization through distance, dimensions, or explicit vectors. The example includes setting up PBC for membrane systems. ```python from insane.pbc import PBC import numpy as np # Hexagonal prism box with specified distance pbc_hex = PBC(shape='hexagonal', distance=(10, 7)) print(f"Box vectors:\n{pbc_hex.box}") print(f"Box dimensions: x={pbc_hex.x:.2f}, y={pbc_hex.y:.2f}, z={pbc_hex.z:.2f}") # Rectangular box with explicit dimensions pbc_rect = PBC(shape='rectangular', xyz=(15, 12, 10)) print(f"Rectangular box: {pbc_rect.x} x {pbc_rect.y} x {pbc_rect.z} nm") # Rhombic dodecahedral box (default for protein systems) pbc_dodec = PBC(shape='optimal', distance=(8, 8)) print(f"Optimal box vectors:\n{pbc_dodec.box}") # Custom box from vectors custom_vectors = ( (10, 0, 0), (5, 8.66, 0), (0, 0, 7) ) pbc_custom = PBC(shape='keep', xyz=custom_vectors) # Box with membrane-specific settings pbc_membrane = PBC( shape='hexagonal', distance=(10, 7), disc=None, # Disc radius for circular membrane patch hole=0, # Hole radius in membrane membrane=True, # System contains membrane protein=[] # List of protein structures ) ``` -------------------------------- ### Get Insane Help (Bash) Source: https://github.com/tsjerk/insane/blob/master/README.md This command displays the list of all available arguments and options for the Insane tool. It is useful for understanding the full capabilities and parameters of the program. ```bash insane -h ``` -------------------------------- ### Setup Protein System with Solvent (Bash) Source: https://github.com/tsjerk/insane/blob/master/README.md This command sets up a protein system by creating a box of solvent around a protein structure. It specifies the output files, the input protein PDB file, the distance for the periodic box, the solvent type ('W' for water), and ion concentration (0 for neutralization). Note that Insane does not prepare the protein itself; martinize should be used for coarse-graining. ```bash insane -o system.gro -p topol.top -f protein.pdb -d 7 -sol W -salt 0 ``` -------------------------------- ### Install Insane Python Module using Pip Source: https://github.com/tsjerk/insane/blob/master/README.md Installs the Insane tool as a Python module using pip. This makes the 'insane' command available in the system's PATH. It's recommended to use virtual environments for managing Python packages. ```bash pip install --user insane ``` -------------------------------- ### Setup Lipid Bilayer Around Proteins (Python) Source: https://context7.com/tsjerk/insane/llms.txt This Python code snippet shows the import statements for functions related to membrane setup in Insane. The `setup_membrane` function is central to generating lipid bilayers around proteins, handling leaflet composition and placement, while `Structure` and `PBC` are supporting classes for system representation and boundary conditions. ```python from insane.core import setup_membrane, old_main from insane.structure import Structure from insane.pbc import PBC ``` -------------------------------- ### Build Simple POPC Bilayer with Water and Ions (CLI) Source: https://context7.com/tsjerk/insane/llms.txt This command-line example demonstrates creating a basic POPC lipid bilayer system with water and ions. It specifies the lipid type, box dimensions, solvent, salt concentration, and output file names for coordinates and topology. ```bash # Create a simple POPC bilayer with water and ions insane -l POPC -d 10 -dz 7 -sol W -salt 0.15 -o bilayer.gro -p topol.top # Output shows system composition: # ; X: 10.000 (17 bins) Y: 10.000 (17 bins) in upper leaflet # ; X: 10.000 (17 bins) Y: 10.000 (17 bins) in lower leaflet # ; 289 lipids in upper leaflet, 289 lipids in lower leaflet # ; Charge of protein: 0.000000 # ; Charge of membrane: 0.000000 # ; Total charge: 0.000000 ``` -------------------------------- ### Combine Molecular Structures Source: https://context7.com/tsjerk/insane/llms.txt This example shows how to combine multiple molecular structures into a single system. It assumes a pre-built membrane structure and demonstrates concatenation and printing the total number of atoms. Dependencies include the 'insane' library and 'Structure' class. ```python membrane = Structure() # Assume pre-built system = protein + membrane print(f"Combined system has {len(system)} atoms") ``` -------------------------------- ### Build Complex Ternary Lipid Mixture with Asymmetry (CLI) Source: https://context7.com/tsjerk/insane/llms.txt This command-line example shows how to build a more complex membrane system using a ternary lipid mixture with different compositions in the upper and lower leaflets. It also specifies box dimensions, solvent mixture, and salt concentration. ```bash # Create a complex ternary lipid mixture with asymmetry insane \ -o complex.gro -p topol.top \ -x 20 -y 20 -z 10 \ -l DPPC:4 -l DIPC:3 -l CHOL:3 \ -u POPC:6 -u POPE:4 \ -sol W:90 -sol WF:10 \ -salt 0.15 ``` -------------------------------- ### Insert Protein into POPC Bilayer with Polarizable Water (CLI) Source: https://context7.com/tsjerk/insane/llms.txt This command-line example demonstrates inserting a transmembrane protein (from a PDB file) into a POPC bilayer using polarizable water and ions. It specifies the protein structure file, lipid type, solvent, salt concentration, box dimensions, periodic boundary conditions, and output files. ```bash # Insert transmembrane protein in POPC bilayer with polarizable water insane \ -f protein_cg.pdb \ -l POPC \ -sol PW \ -salt 0.15 \ -d 10 -pbc hexagonal \ -center \ -o system.gro -p topol.top # Expected output files: system.gro - coordinates of all atoms in GROMACS format topol.top - topology file listing molecules and counts ``` -------------------------------- ### Complete System Building Workflow Source: https://context7.com/tsjerk/insane/llms.txt This snippet outlines the parameters for the `old_main()` function, which orchestrates the end-to-end construction of a membrane simulation system. It covers defining input/output files, periodic boundary conditions, lipid composition, protein options, solvent and ion concentrations, and lipid definitions. ```python from insane.core import old_main, write_summary, write_structure, write_top, system_title # Define complete system parameters options = { # Input/Output 'solute': ['protein.pdb'], 'output': 'system.gro', 'topology': 'topol.top', # Periodic boundary conditions 'pbc': 'hexagonal', 'distance': 10, 'zdistance': 7, 'xvector': None, 'yvector': None, 'zvector': None, 'box': None, # Lipid composition 'lower': [('M3.POPC', 0, 3), ('M3.POPE', 0, 1)], 'upper': [('M3.POPC', 0, 3), ('M3.POPE', 0, 1)], 'area': 0.6, 'uparea': None, 'asymmetry': 0, 'hole': 0, 'disc': None, 'indist': 1.0, 'beaddist': 0.3, 'randkick': 0.1, 'norotate': False, # Protein options 'center': True, 'orient': False, 'rotate': None, 'memshift': 0, 'inside': False, 'fudge': 0.1, 'origriddist': 1.0, 'oripower': 4.0, 'protdensity': 20, 'protradius': 0, # Solvent and salt 'solvent': [('W', 0, 1)], 'soldiam': 0.5, 'solrandom': 0.1, 'solexcl': 1.5, 'salt': '0.15', 'charge': 'auto', # Lipid definitions 'forcefield': 'M3', 'lipnames': [], 'lipheads': [], 'liplinks': [], 'liptails': [], 'lipcharge': [], 'molfile': [], 'lipdensity': 20, 'lipradius': 0.33 } # Example of calling the function (commented out as it's illustrative) # old_main(options) ``` -------------------------------- ### Build a Transmembrane Protein System with Insane Source: https://github.com/tsjerk/insane/blob/master/README.md This command demonstrates building a simulation system with a transmembrane protein, a lipid bilayer, water, and ions. It specifies the protein PDB file, lipid type, solvent composition, salt concentration, and output file names for the structure and topology. ```bash insane \ -f cg1a0s.pdb \ -l POPC \ -sol W:90 -sol WF:10 \ -salt 0.8 \ -o system.gro -p topol.top ``` -------------------------------- ### Define System Parameters and Build Membrane with Insane Source: https://context7.com/tsjerk/insane/llms.txt Configures simulation parameters and builds a lipid membrane. It sets options for lipid composition, area, asymmetry, and force field, then uses these to construct the membrane using provided PBC and protein structure. ```python from insane.core import setup_membrane from insane.pbc import PBC from insane.structure import Structure # Define system parameters options = { 'lower': [('M3.POPC', 0, 1), ('M3.POPE', 0, 1)], # (name, absolute, relative) 'upper': [('M3.POPC', 0, 1), ('M3.POPE', 0, 1)], 'area': 0.6, # Area per lipid in nm² 'uparea': 0.6, # Upper leaflet area per lipid 'asymmetry': 0, # Leaflet asymmetry (difference in lipid count) 'hole': 0, # Hole radius in nm 'disc': None, # Disc radius in nm 'beaddist': 0.3, # Bead spacing in z-direction 'randkick': 0.1, # Random displacement 'norotate': False, # Allow lipid rotation 'inside': False, # Place lipids inside protein 'forcefield': 'M3', # Force field version 'fudge': 0.1, # Overlap tolerance 'indist': 1.0, # Inter-leaflet distance 'protdensity': 20, # Protein occupancy sphere points 'protradius': 0, # Protein occupancy radius 'lipnames': [], # Custom lipid names 'lipheads': [], # Custom lipid heads 'liplinks': [], # Custom lipid linkers 'liptails': [], # Custom lipid tails 'lipcharge': [], # Custom lipid charges 'molfile': [] # External lipid definition files } # Setup periodic boundary conditions pbc = PBC(shape='hexagonal', xyz=(10, 10, 10)) # Load protein structure (if any) protein = Structure() # Empty for membrane-only system # Build membrane lipid_spec = ( (['M3.POPC', 'M3.POPE'], [0, 0], [1, 1]), # Lower leaflet (['M3.POPC', 'M3.POPE'], [0, 0], [1, 1]) # Upper leaflet ) membrane, molecules = setup_membrane(pbc, protein, lipid_spec, options) print(f"Membrane contains {len(membrane.atoms)} atoms") print(f"Molecules added: {molecules}") ``` -------------------------------- ### Build and Write Molecular Dynamics System (Python) Source: https://context7.com/tsjerk/insane/llms.txt This code snippet demonstrates the core functionality of the Insane script. It builds a complete molecular dynamics system by combining molecules, proteins, membranes, and solvent, then writes summary information, a system title, structure file, and topology file. It relies on functions like 'old_main', 'write_summary', 'system_title', 'write_structure', and 'write_top'. ```python molecules, protein, membrane, solvent, lipids, box = old_main(**options) # Write summary information write_summary(protein, membrane, solvent) # Generate system title title = system_title(membrane, protein, lipids) # Write structure file atoms = protein + membrane + solvent write_structure( output=options['output'], title=title, atoms=atoms, box=box ) # Write topology write_top(options['topology'], molecules, title) print("System building complete!") print(f"Structure written to: {options['output']}") print(f"Topology written to: {options['topology']}") ``` -------------------------------- ### Add Solvent and Ions with Insane Source: https://context7.com/tsjerk/insane/llms.txt Fills a simulation system with solvent and ions. It places solvent molecules on a grid, excluding protein and membrane regions, and automatically adds ions for neutralization or specified salt concentration. ```python from insane.core import setup_solvent from insane.structure import Structure from insane.pbc import PBC # Setup system components pbc = PBC(shape='rectangular', xyz=(15, 15, 10)) protein = Structure() # Empty structure membrane = Structure() # Pre-built membrane # Define solvent options options = { 'solvent': [('W', 0, 90), ('WF', 0, 10)], # 90% water, 10% antifreeze 'soldiam': 0.5, # Solvent bead diameter in nm 'solrandom': 0.1, # Random displacement 'solexcl': 1.5, # Exclusion distance from membrane center 'salt': '0.15', # Salt concentration in M 'charge': 'auto', # System charge (auto-detect) 'lipradius': 0.33, # Lipid exclusion radius 'lipdensity': 20 # Lipid exclusion sphere points } # Add solvent and ions solvent, solvent_molecules = setup_solvent(pbc, protein, membrane, options) print(f"Solvent structure contains {len(solvent.atoms)} atoms") print(f"Solvent composition: {solvent_molecules}") # Output example: [('W', 4521), ('WF', 502), ('NA', 45), ('CL', 45)] print(f"System charge after solvation: {solvent.charge}") # Neutralize system without setting concentration options['salt'] = '0' solvent_neutral, molecules_neutral = setup_solvent(pbc, protein, membrane, options) print(f"Neutralized system: {molecules_neutral}") # Output: [('W', 4521), ('WF', 502), ('CL', 12)] # Only neutralizing ions added ``` -------------------------------- ### Write Output Structure (GRO format) Source: https://context7.com/tsjerk/insane/llms.txt This code demonstrates writing a combined molecular system to a file in GRO format. It specifies the output filename, title, atomic data, and simulation box dimensions. Dependencies include 'numpy' and the 'write_structure' function from 'insane'. ```python import numpy as np box = np.array([[15, 0, 0], [0, 15, 0], [0, 0, 10]]) write_structure( output='system.gro', title='Protein in membrane', atoms=system, box=box ) ``` -------------------------------- ### Generate GROMACS Topology File Source: https://context7.com/tsjerk/insane/llms.txt This Python snippet illustrates how to generate GROMACS topology files using the `write_top` function from the `insane.core` module. It shows creating both a full topology file and a simplified molecule list for appending to existing topologies. The input is a list of molecule types and their counts, along with a system title. ```python from insane.core import write_top # Molecule list from system building molecules = [ ('Protein', 1), ('M3.POPC', 256), ('M3.POPE', 128), ('M3.CHOL', 64), ('W', 5000), ('NA', 50), ('CL', 50) ] system_title = "Protein in POPC:POPE:CHOL (4:2:1) membrane with 0.15M NaCl" # Write full topology file write_top('topol.top', molecules, system_title) # Write simplified topology (for appending to existing file) write_top('', molecules, system_title) ``` -------------------------------- ### Insert Protein into Membrane (Bash) Source: https://github.com/tsjerk/insane/blob/master/README.md This command inserts a protein into a lipid bilayer. It specifies output files, box distance, hexagonal periodic boundary conditions, the lipid type ('POPC'), solvent type ('PW' for polarizable water), the input protein structure file, and centers the protein in the box. This is used for building membrane systems with proteins. ```bash insane \ -o system.gro -p topol.top \ -d 10 -pbc hexagonal \ -l POPC -sol PW \ -f protein.gro -center ``` -------------------------------- ### Manipulate and Build Lipid Molecules (Python) Source: https://context7.com/tsjerk/insane/llms.txt This Python code snippet demonstrates how to load predefined lipid types from Insane's library, access their properties, and build their coarse-grained bead coordinates based on a specified area per lipid. It also shows how to define and build a custom lipid from scratch. ```python from insane.lipids import Lipid, get_lipids # Load predefined lipid library liplist = get_lipids() # Access a specific lipid (e.g., POPC in Martini 3) popc = liplist['M3.POPC'] print(f"Lipid: {popc.name}, Charge: {popc.charge}") # Build lipid coordinates with specific area per lipid coords = popc.build(diam=0.775) # diam = sqrt(0.6 nm²) for bead, x, y, z in coords: print(f"Bead: {bead:4s} Position: ({x:6.3f}, {y:6.3f}, {z:6.3f})") # Define custom lipid from head/link/tail specification custom_lipid = Lipid( name="CUSTOM", head=["C", "P"], # Choline and Phosphate link=["G", "G"], # Two glycerol linkers tail=["CCCC", "CDCC"], # Two tail chains charge=0.0, area=0.65 ) custom_coords = custom_lipid.build() print(f"Built custom lipid with {len(custom_coords)} beads") ``` -------------------------------- ### Build a Ternary Lipid Mixture Bilayer with Insane Source: https://github.com/tsjerk/insane/blob/master/README.md This command constructs a complex lipid bilayer system with a ternary mixture of lipids (DPPC, DIPC, CHOL) and a mixed solvent (Water and Anti-freeze Water). It defines an orthorhombic box and specifies the ratios of different lipid types. ```bash insane \ -o bilayer.gro -p topol.top \ -x 20 -y 20 -z 10 \ -l DPPC:4 -l DIPC:3 -l CHOL:3 \ -sol W:90 -sol WF:10 ``` -------------------------------- ### Create a Simple Hydrated Lipid Bilayer with Insane Source: https://github.com/tsjerk/insane/blob/master/README.md This command creates a hydrated lipid bilayer system. It specifies the lipid type (POPC), box dimensions (hexagonal prism), solvent type (Water), and output files for the structure (GRO) and topology (TOP). ```bash insane -l POPC -d 10 -dz 7 -sol W -o bilayer.gro -p topol.top ``` -------------------------------- ### Handle Molecular Structures with Insane's Structure Class Source: https://context7.com/tsjerk/insane/llms.txt Manages molecular structures from PDB or GRO files. The Structure class provides methods for centering, rotation, orientation, and calculating properties like charge, diameter, and cross-sectional area. ```python from insane.structure import Structure, write_structure import numpy as np # Read protein structure from file protein = Structure('protein_cg.pdb', options={'center': True, 'orient': False, 'rotate': None, 'memshift': 0, 'origriddist': 1.0, 'oripower': 4.0}) # Get structure properties print(f"Number of atoms: {len(protein)}") print(f"System charge: {protein.charge}") print(f"Center of mass: {protein.center}") print(f"Diameter: {protein.diam():.2f} nm") print(f"XY plane diameter: {protein.diamxy():.2f} nm") # Calculate membrane cross-section area area = protein.areaxy(lowerbound=-2.4, upperbound=2.4, spacing=0.1) print(f"Protein area in membrane: {area:.2f} nm²") ``` -------------------------------- ### Manipulate Protein Coordinates Source: https://context7.com/tsjerk/insane/llms.txt This snippet demonstrates how to manipulate atomic coordinates of a protein structure using Insane. It includes translation, centering, and various rotation methods. Dependencies include the 'insane' library and a 'protein' object. ```python protein.coord += (5, 5, 0) # Translate by vector protein.center = (10, 10, 5) # Move center to specific position protein.rotate('random') # Random rotation in xy-plane protein.rotate('princ') # Align to principal axes protein.rotate('45') # Rotate by 45 degrees ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.