Skip to content

Commit

Permalink
solve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
pm-blanco committed Mar 14, 2024
1 parent 6477726 commit 382e81c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 42 deletions.
40 changes: 15 additions & 25 deletions pyMBE.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class pymbe_library():

"""
The library for the Molecular Builder for ESPResSo (pyMBE)
Expand Down Expand Up @@ -938,8 +939,9 @@ def create_residue(self, name, espresso_system, number_of_residues, central_bead
on_surface=True)[0]
else:
bead_position=self.generate_trial_perpendicular_vector(vector=backbone_vector,
center=central_bead_position,
radius=l0)
origin=central_bead_position,
magnitude=l0)

side_bead_id = self.create_particle(name=side_chain_element,
espresso_system=espresso_system,
position=[bead_position],
Expand Down Expand Up @@ -971,8 +973,8 @@ def create_residue(self, name, espresso_system, number_of_residues, central_bead
on_surface=True)[0]
else:
residue_position=self.generate_trial_perpendicular_vector(vector=backbone_vector,
center=central_bead_position,
radius=l0)
origin=central_bead_position,
magnitude=l0)
lateral_residue_info = self.create_residue(name=side_chain_element, espresso_system=espresso_system,
number_of_residues=1, central_bead_position=[residue_position],use_default_bond=use_default_bond)
lateral_residue_dict=list(lateral_residue_info.values())[0]
Expand Down Expand Up @@ -1492,8 +1494,7 @@ def find_value_from_es_type(self, es_type, column_name):
"""
idx = self.pd.IndexSlice
for state in ['state_one', 'state_two']:
index = self.np.where(self.df[(state, 'es_type')] == es_type)[0]

index = self.np.where(self.df[(state, 'es_type')] == es_type)[0]
if len(index) > 0:
if column_name == 'label':
label = self.df.loc[idx[index[0]], idx[(state,column_name)]]
Expand Down Expand Up @@ -1530,42 +1531,32 @@ def generate_coordinates_outside_sphere(self, center, radius, max_dist, n_sample
counter += 1
return coord_list

def generate_trial_perpendicular_vector(self,vector,center,radius):
def generate_trial_perpendicular_vector(self,vector,origin,magnitude):
"""
Generates an orthogonal vector to the input `vector`.
Args:
vector(`lst`): arbitrary vector.
center(`lst`): origin of the orthogonal vector.
radius(`float`): magnitude of the orthogonal vector.
origin(`lst`): origin of the orthogonal vector.
magnitude(`float`): magnitude of the orthogonal vector.
Returns:
perpendicular_vector: Orthogonal vector with the same magnitude as the input vector.
(`lst`): Orthogonal vector with the same magnitude as the input vector.
"""

# FIXME:
# We should consider renaming the input arguments for clarity
# center --> origin
# radius --> magnitude

np_vec = self.np.array(vector)

np_vec = self.np.array(vector)
if self.np.all(np_vec == 0):
raise ValueError('Zero vector')

# Generate a random vector with the same size as the input vector
random_vector = self.generate_trialvectors(center=center,
radius=radius,
random_vector = self.generate_trialvectors(center=[0,0,0],
radius=1,
n_samples=1,
on_surface=True)[0]

# Project the random vector onto the input vector and subtract the projection
projection = self.np.dot(random_vector, np_vec) * np_vec
perpendicular_vector = random_vector - projection
# Normalize the perpendicular vector to have the same magnitude as the input vector
perpendicular_vector /= self.np.linalg.norm(perpendicular_vector)
return center+perpendicular_vector*radius

return origin+perpendicular_vector*magnitude

def generate_trialvectors(self, center, radius, n_samples, seed=None, on_surface=False):
"""
Expand Down Expand Up @@ -1594,7 +1585,6 @@ def generate_trialvectors(self, center, radius, n_samples, seed=None, on_surface
# make the samples lie on the surface of the unit hypersphere
normalize_radii = self.np.linalg.norm(samples, axis=1)[:, self.np.newaxis]
samples /= normalize_radii

if not on_surface:
# make the samples lie inside the hypersphere with the correct density
uniform_points = rng.uniform(size=n_samples)[:, self.np.newaxis]
Expand Down
4 changes: 2 additions & 2 deletions samples/branched_polyampholyte.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
pmb = pyMBE.pymbe_library()

# Load some functions from the handy_scripts library for convinience
from handy_scripts.handy_functions import setup_langevin_dynamics
from handy_scripts.handy_functions import block_analyze
from lib.handy_functions import setup_langevin_dynamics
from lib.analysis import block_analyze

# The trajectories of the simulations will be stored using espresso built-up functions in separed files in the folder 'frames'
if not os.path.exists('./frames'):
Expand Down
14 changes: 7 additions & 7 deletions samples/peptide.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
pmb = pyMBE.pymbe_library()

# Load some functions from the handy_scripts library for convinience
from handy_scripts.handy_functions import setup_electrostatic_interactions
from handy_scripts.handy_functions import minimize_espresso_system_energy
from handy_scripts.handy_functions import setup_langevin_dynamics
from handy_scripts.handy_functions import block_analyze
from lib.handy_functions import setup_electrostatic_interactions
from lib.handy_functions import minimize_espresso_system_energy
from lib.handy_functions import setup_langevin_dynamics
from lib.analysis import block_analyze

# The trajectories of the simulations will be stored using espresso built-up functions in separed files in the folder 'frames'
if not os.path.exists('./frames'):
Expand All @@ -39,15 +39,15 @@

# Peptide parameters

sequence = 'nGEGGHc'
sequence = 'nEEEEEc'
model = '2beadAA' # Model with 2 beads per each aminoacid
pep_concentration = 5.56e-4 *pmb.units.mol/pmb.units.L
N_peptide_chains = 4

# Load peptide parametrization from Lunkad, R. et al. Molecular Systems Design & Engineering (2021), 6(2), 122-131.

path_to_interactions=pmb.get_resource("reference_parameters/interaction_parameters/Lunkad2021.txt")
path_to_pka=pmb.get_resource("reference_parameters/pka_sets/Hass2015.txt")
path_to_interactions=pmb.get_resource("parameters/peptides/Lunkad2021.txt")
path_to_pka=pmb.get_resource("parameters/pka_sets/Hass2015.txt")
pmb.load_interaction_parameters (filename=path_to_interactions)
pmb.load_pka_set (path_to_pka)

Expand Down
8 changes: 4 additions & 4 deletions samples/peptide_mixture_grxmc_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
os.makedirs('./frames')

#Import functions from handy_functions script
from handy_scripts.handy_functions import minimize_espresso_system_energy
from handy_scripts.handy_functions import block_analyze
from lib.handy_functions import minimize_espresso_system_energy
from lib.analysis import block_analyze

# Simulation parameters
pmb.set_reduced_units(unit_length=0.4*pmb.units.nm)
Expand All @@ -46,8 +46,8 @@
N_peptide2_chains = 10

# Load peptide parametrization from Lunkad, R. et al. Molecular Systems Design & Engineering (2021), 6(2), 122-131.
path_to_interactions=pmb.get_resource("reference_parameters/interaction_parameters/Lunkad2021.txt")
path_to_pka=pmb.get_resource("reference_parameters/pka_sets/Hass2015.txt")
path_to_interactions=pmb.get_resource("parameters/peptides/Lunkad2021.txt")
path_to_pka=pmb.get_resource("parameters/pka_sets/Hass2015.txt")
pmb.load_interaction_parameters (filename=path_to_interactions)
pmb.load_pka_set (path_to_pka)

Expand Down
8 changes: 4 additions & 4 deletions samples/peptide_mixture_grxmc_unified_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
os.makedirs('./frames')

#Import functions from handy_functions script
from handy_scripts.handy_functions import minimize_espresso_system_energy
from handy_scripts.handy_functions import block_analyze
from lib.handy_functions import minimize_espresso_system_energy
from lib.analysis import block_analyze

# Simulation parameters
pmb.set_reduced_units(unit_length=0.4*pmb.units.nm)
Expand All @@ -47,8 +47,8 @@


# Load peptide parametrization from Lunkad, R. et al. Molecular Systems Design & Engineering (2021), 6(2), 122-131.
path_to_interactions=pmb.get_resource("reference_parameters/interaction_parameters/Lunkad2021.txt")
path_to_pka=pmb.get_resource("reference_parameters/pka_sets/Hass2015.txt")
path_to_interactions=pmb.get_resource("parameters/peptides/Lunkad2021.txt")
path_to_pka=pmb.get_resource("parameters/pka_sets/Hass2015.txt")
pmb.load_interaction_parameters (filename=path_to_interactions)
pmb.load_pka_set (path_to_pka)

Expand Down

0 comments on commit 382e81c

Please sign in to comment.