Skip to content

Commit

Permalink
adds vsites as bonds between base particles and vsite
Browse files Browse the repository at this point in the history
  • Loading branch information
BartBruininks committed Oct 10, 2023
1 parent 18372f1 commit e58cca6
Showing 1 changed file with 121 additions and 0 deletions.
121 changes: 121 additions & 0 deletions package/MDAnalysis/topology/ITPParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ def __init__(self, name):
'angles': self.parse_angles,
'dihedrals': self.parse_dihedrals,
'constraints': self.parse_constraints,
'virtual_sites1' : self.parse_virtual_sites1, #BMHB
'virtual_sites2' : self.parse_virtual_sites2, #BMHB
'virtual_sites3' : self.parse_virtual_sites3, #BMHB
'virtual_sites4' : self.parse_virtual_sites4, #BMHB
'virtual_sitesn' : self.parse_virtual_sitesn, #BMHB
'settles': self.parse_settles
}

Expand Down Expand Up @@ -349,6 +354,122 @@ def parse_dihedrals(self, line):

def parse_constraints(self, line):
self.add_param(line, self.bonds, n_funct=2, funct_values=(1, 2))

def parse_virtual_sites1(self, line): # BMHB
# [ virtual_sites[n1234] ] are formats of constructing
# a particle geometrically based on the base particles
# that define it, with some underlying values to
# specify the distance of the vsite with respect to the
# base particles. In GMX there are multiple forms of
# vsites, but we are going to parse them all in a similar
# manner. We add a bonds between the vsite and all of its
# base particles. Example: vsite3 has first three elements as
# the the base particles the 4th element is the vsite. Thus
# 3 bonds are created 1-4, 2-4, 3-4. This is the same for
# all vsites with a different number so vsite2 adds 2 bonds.
n_funct = 1
elements = line.split()
base_indices = elements[:n_funct]
vsite_index = elements[n_funct]
funct_value = elements[n_funct+1]
# Add every element vsite pair as a bond.
for base_index in base_indices:
temp_line = f'{base_index} {vsite_index} {funct_value} 0.0 0.0'
self.add_param(temp_line, self.bonds, n_funct=2,
funct_values=(1,))


def parse_virtual_sites2(self, line): # BMHB
# [ virtual_sites[n1234] ] are formats of constructing
# a particle geometrically based on the base particles
# that define it, with some underlying values to
# specify the distance of the vsite with respect to the
# base particles. In GMX there are multiple forms of
# vsites, but we are going to parse them all in a similar
# manner. We add a bonds between the vsite and all of its
# base particles. Example: vsite3 has first three elements as
# the the base particles the 4th element is the vsite. Thus
# 3 bonds are created 1-4, 2-4, 3-4. This is the same for
# all vsites with a different number so vsite2 adds 2 bonds.
n_funct = 2
elements = line.split()
base_indices = elements[:n_funct]
vsite_index = elements[n_funct]
funct_value = elements[n_funct+1]
# Add every element vsite pair as a bond.
for base_index in base_indices:
temp_line = f'{base_index} {vsite_index} {funct_value} 0.0 0.0'
self.add_param(temp_line, self.bonds, n_funct=2,
funct_values=(1, 2,))

def parse_virtual_sites3(self, line): # BMHB
# [ virtual_sites[n1234] ] are formats of constructing
# a particle geometrically based on the base particles
# that define it, with some underlying values to
# specify the distance of the vsite with respect to the
# base particles. In GMX there are multiple forms of
# vsites, but we are going to parse them all in a similar
# manner. We add a bonds between the vsite and all of its
# base particles. Example: vsite3 has first three elements as
# the the base particles the 4th element is the vsite. Thus
# 3 bonds are created 1-4, 2-4, 3-4. This is the same for
# all vsites with a different number so vsite2 adds 2 bonds.
n_funct = 3
elements = line.split()
base_indices = elements[:n_funct]
vsite_index = elements[n_funct]
funct_value = elements[n_funct+1]
# Add every element vsite pair as a bond.
for base_index in base_indices:
temp_line = f'{base_index} {vsite_index} {funct_value} 0.0 0.0'
self.add_param(temp_line, self.bonds, n_funct=2,
funct_values=(1, 2, 3, 4,))

def parse_virtual_sites4(self, line): # BMHB
# [ virtual_sites[n1234] ] are formats of constructing
# a particle geometrically based on the base particles
# that define it, with some underlying values to
# specify the distance of the vsite with respect to the
# base particles. In GMX there are multiple forms of
# vsites, but we are going to parse them all in a similar
# manner. We add a bonds between the vsite and all of its
# base particles. Example: vsite3 has first three elements as
# the the base particles the 4th element is the vsite. Thus
# 3 bonds are created 1-4, 2-4, 3-4. This is the same for
# all vsites with a different number so vsite2 adds 2 bonds.
n_funct = 4
elements = line.split()
base_indices = elements[:n_funct]
vsite_index = elements[n_funct]
funct_value = elements[n_funct+1]
# Add every element vsite pair as a bond.
for base_index in base_indices:
temp_line = f'{base_index} {vsite_index} {funct_value} 0.0 0.0'
self.add_param(temp_line, self.bonds, n_funct=2,
funct_values=(2,))

def parse_virtual_sitesn(self, line): # BMHB
# [ virtual_sites[n1234] ] are formats of constructing
# a particle geometrically based on the base particles
# that define it, with some underlying values to
# specify the distance of the vsite with respect to the
# base particles. In GMX there are multiple forms of
# vsites, but we are going to parse them all in a similar
# manner. We add a bonds between the vsite and all of its
# base particles. Example: vsite3 has first three elements as
# the the base particles the 4th element is the vsite. Thus
# 3 bonds are created 1-4, 2-4, 3-4. This is the same for
# all vsites with a different number so vsite2 adds 2 bonds.
elements = line.split()
n_funct = len(elements)-2 # COG of all particles plus vsite
base_indices = elements[:n_funct]
vsite_index = elements[n_funct]
funct_value = elements[n_funct+1]
# Add every element vsite pair as a bond.
for base_index in base_indices:
temp_line = f'{base_index} {vsite_index} {funct_value} 0.0 0.0'
self.add_param(temp_line, self.bonds, n_funct=2,
funct_values=(2,))

def parse_settles(self, line):
# [ settles ] is a triangular constraint for
Expand Down

0 comments on commit e58cca6

Please sign in to comment.