From 8599c00207463211c1e9d4f562d6836e559c55ec Mon Sep 17 00:00:00 2001 From: lunamorrow Date: Mon, 20 Jan 2025 14:44:54 +1000 Subject: [PATCH 1/2] Adjust automated builder messages, and commited current working state for review/assistance with the 'dihedral_shuffler' method --- polyconf/polyconf/Polymer.py | 19 +++++++++++++++++-- polyconf/polyconf/polyconf_automatic.py | 9 ++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/polyconf/polyconf/Polymer.py b/polyconf/polyconf/Polymer.py index 33f16b9..bf8895c 100644 --- a/polyconf/polyconf/Polymer.py +++ b/polyconf/polyconf/Polymer.py @@ -103,6 +103,17 @@ def maxresid(self): return n + def newresid(self): + """ + Returns next numerical resid possible for the polymer + + :return: the polymer's current highest resid plus 1 + :rtype: int + """ + n = max(self.polymer.residues.resids) + 1 + return n + + def extend(self, monomer, n, nn, names, joins, ortho=[1,1,1], linearise=False, beta=0): """ @@ -430,8 +441,12 @@ def dihedral_solver(self,pairlist,dummy='X*',cutoff=0.7): done=True if failed or i<0: # hard coded to detect failure if you stop at i<=0 because detecting this automatically wasn't working print('Could not reach a valid conformation') - print('Perhaps you should try building a pseudolinear geometry with .extend(linearize=True) or randomising all dihedrals with shuffler(), and then try solving a conformation again') - return(failed or i<0) + print('Perhaps you should try building a pseudolinear geometry with .extend(linearize=True) or randomising all dihedrals with shuffler(), and then try solving a conformation again') + return True + else: + return False + # return(failed or i<0) + # return(failed) def shuffler(self,pairlist,dummy='X*',cutoff=0.5,clashcheck=False): """ diff --git a/polyconf/polyconf/polyconf_automatic.py b/polyconf/polyconf/polyconf_automatic.py index 1f48de7..6696e32 100644 --- a/polyconf/polyconf/polyconf_automatic.py +++ b/polyconf/polyconf/polyconf_automatic.py @@ -123,16 +123,19 @@ def main(): CN=polymer.gen_pairlist(a1=args.rotate[0],a2=args.rotate[1],first_resid=1,last_resid=args.length,mult=3) for i in range(args.nconfs): - failed = True + # failed = True polymerToShuffle = polymer.copy() for j in range(args.shuffles): - failed = polymerToShuffle.dihedral_solver(CN,dummy=args.joiners,cutoff=0.7) + failed = polymerToShuffle.dihedral_solver(CN, cutoff=0.7) if failed == False: print(f"successfully generated conformation {i+1} without clashes") Saver = PDB(polymerToShuffle) Saver.cleanup() # center in box - Saver.save(dummyAtoms=args.joiners,fname=f'{args.name}_solved{i+1}') + Saver.save(fname=f'{args.name}_solved{i+1}') print(f"Saved polymer geometry {i+1} as '{fname}_solved{i+1}.pdb'\n\n") break + else: + print("Shuffling geometry and retrying") + polymerToShuffle.shuffler(CN,dummy='X*',cutoff=0.5,clashcheck=False) if failed == True: print(f"Unable to generate conformation number {i+1} - moving onto the next conformation\n\n") \ No newline at end of file From 2e84811cb1f9bea758f96d30f9f1cfe71347b919 Mon Sep 17 00:00:00 2001 From: lunamorrow Date: Tue, 28 Jan 2025 13:29:53 +1000 Subject: [PATCH 2/2] Reset dihedral_solver() in PolyConf to same function as is main --- polyconf/polyconf/Polymer.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/polyconf/polyconf/Polymer.py b/polyconf/polyconf/Polymer.py index cacea17..a081a69 100644 --- a/polyconf/polyconf/Polymer.py +++ b/polyconf/polyconf/Polymer.py @@ -425,8 +425,6 @@ def dihedral_solver(self,pairlist,dummy='X*',cutoff=0.7): while not (done) : with tqdm(total=steps) as pbar: while i < steps and i >=0: - - dh=pairlist[i] check=self.dist(a1=dh['a1'],a1_resid=dh['a1_resid'],a2=dh['a2'],a2_resid=dh['a2_resid'],dummy=dummy) if check > cutoff and not retry: @@ -457,8 +455,6 @@ def dihedral_solver(self,pairlist,dummy='X*',cutoff=0.7): return True else: return False - # return(failed or i<0) - # return(failed) def shuffler(self,pairlist,dummy='X*',cutoff=0.5,clashcheck=False): """