three monomers crosslinking algorithm

Dear all,

    I am working on crosslinking algorithm initially from Dr. Stephen Todd script.

I am using three monomers, so I need to modify the scritp to fit the conditions.

Based on the closecontact calculation, I have to check the distaces.

In the script, I randomly pick up one atom and then I should check the distance for three other reactive atoms. 

Surely, these three other reactive atoms are not involved in the molecule which includes the randomly picked atom.

Explanation.

1. There are three monomers. They have two reactive atoms at the ends of monomers.

2. I randomly pack the bunch of monomers in the unit cell.

2. Pick up one reactive atom(atom1) from one of the three monomers (monomer1 or monomer2 or monomer3).

3. Check distaces from the picked atom to three close reactive atoms(atom2, atom3, atom4) within cutoff distance by closecontact criteria.--->atom2 from monomer1, atom3 from monomer2, atom4 from monomer3

    (The closest distace within the cutoff distance)

4. Multifly the correction factors to the distances.

5. Then, create bond between atom1 and an atom which have the lowest value.

What I am concernd about this scipt is that when I use "CalculateColseContacts",  I think that the line 1~30 only checks the one atom distance but not three distances by closecontact criteria( I marked the line number).

How can I modify this script for checking three distances?

Thanks.

Best regards,

Changwoon Jang

The following sub script is a basis from Dr. Stephen Todd.

===================================================================

sub createTheConnections {

my (\$doc1, \$dist) = @_;
 
# To avoid the issue of close contacts on a connected system, re-calculate the close contacts
# based on the new sets

my \$continue = 0; # Used to define whether dynamics calculations will occur

# Calculate close contacts

Tools->BondCalculation->ChangeSettings([DistanceCriterionMode=> "Absolute" ,ExclusionMode => "Set", MaxAbsoluteDistance => \$dist]);
 
my \$closeContacts = \$doc->CalculateCloseContacts;
 
\$textDoc->Append( "There are ".\$closeContacts->Count." contacts\n");
 
# Randomize the close contacts

my @shuffledCloseContacts = shuffle(@\$closeContacts);

# Go through each close contact and create the bonds

my \$newBondCounter = 0;

===================================================================

1 if (\$atom1Name eq "\$xlinkerReactiveAtom") {

3             my \$xLinkermoleculeAtom1 = \$atom1;
4     
5             if (\$atom2Name eq "\$oligomerReactiveAtom1") {
6   
7                        my \$oligomermoleculeAtom1 = \$atom2;
8   
9                        my \$Distance1 = \$doc1 -> CreateDistance([\$xLinkermoleculeAtom1, \$oligomermoleculeAtom1]);
10                      my \$ReactiveDistance1 = \$Distance1 * \$ReactiveRatio_S_VE1;
11  
12             }
13 
14            if (\$atom2Name eq "\$oligomerReactiveAtom2") {
15  
16                      my \$oligomermoleculeAtom2 = \$atom2;
17   
18                      my \$Distance2 = \$doc1 -> CreateDistance([\$xLinkermoleculeAtom1, \$oligomermoleculeAtom2]);
19                      my \$ReactiveDistance2 = \$Distance2 * \$ReactiveRatio_S_VE2;
20      
21              }
22  
23              if (\$atom2Name eq "\$xlinkerReactiveAtom") {
24   
25                      my \$xLinkermoleculeAtom2 = \$atom2;
26  
27                      my \$Distance3 = \$doc1 -> CreateDistance([\$xLinkermoleculeAtom1, \$xLinkermoleculeAtom2]);
28                      my \$ReactiveDistance3 = \$Distance3 * \$ReactiveRatio_S_S;
29  
30               }

================================================================================