From 960d374402c723cf3e7927b019bc8423c8085d73 Mon Sep 17 00:00:00 2001 From: dkarlov Date: Sat, 19 Jul 2025 20:23:18 +0100 Subject: [PATCH 1/2] added support for PDB files with more than 100,000 atoms; recent versions of ACEMD between 4.0.0 - 4.0.14 are now working. --- suMD | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/suMD b/suMD index 0774ebd..9bd7174 100644 --- a/suMD +++ b/suMD @@ -86,14 +86,17 @@ class monitor: - wordList = ['ATOM', 'HETATM'] - text = f=open(self.structuref, 'r').read() + wordList = ['ATOM', 'HETA'] + text = open(self.structuref, 'r').readlines() # corrected here: text = f=open(self.structuref, 'r').read() + #return sum([ text.split().count(w) for w in wordList]) ag = AtomGroup() - ag.setBetas([0.]*sum([ text.split().count(w) for w in wordList])) + #ag.setBetas([0.]*sum([ text.split().count(w) for w in wordList])) # does not work for too large systems: there are no space between hetatm records + n_atoms = sum([1 if line[0:4] in wordList else 0 for line in text]) # correction + ag.setBetas([0.]* n_atoms) #structure = parsePDB(sys.argv[1], ag=ag) - self.structure = parsePDB(self.structuref,ag=ag) + self.structure = parsePDB(self.structuref, ag=ag) self.step = step @@ -254,14 +257,17 @@ class suMD: f = open('SUMD.log.tmp', 'w') for line in open('./suMD-Simulation/SUMD.log'): if line[0:8] == 'Step_num': - checkslope = float(line.split()[2]) - checkdistance = float(line.split()[3]) + # if number if steps here overcomes 100 the line cannot be splitted with ' ' + # use trimmmed line + trimmed_lined = line[0:8] + checkslope = float(trimmed_lined.split()[1]) + checkdistance = float(trimmed_lined.split()[2]) if checkslope < self.slopesel or checkdistance < float(self.Bound): - self.last_RightDistance = float(line.split()[3]) - self.wrong_meta = int(line.split()[-1]) - self.right_tricky = int(line.split()[-2]) - self.right_optimus = int(line.split()[-3]) - self.stepsuMD = int(line.split()[1]) + self.last_RightDistance = float(trimmed_lined.split()[2]) + self.wrong_meta = int(trimmed_lined.split()[-1]) + self.right_tricky = int(trimmed_lined.split()[-2]) + self.right_optimus = int(trimmed_lined.split()[-3]) + self.stepsuMD = int(trimmed_lined.split()[0]) for line in open('./suMD-Simulation/SUMD.log'): if line[0:8] == 'Step_num': #maicol ... problema con restart sopra i 100 step [0:7] ??? checkstep = int(line.split()[1]) @@ -352,8 +358,8 @@ class suMD: # funzione per lancio di acemd dove si esplicitano il device e quale input utilizzare def Run_Acemd(self, n_device, Input_run): - - os.system('{} --device {} {} > suMD-Simulation_step.log'.format(self.acemd, n_device, Input_run)) + print('{} --device {} {} > suMD-Simulation_step.log'.format(self.acemd, n_device, Input_run)) + os.system('{} --input {} --device {} > suMD-Simulation_step.log'.format(self.acemd, Input_run, n_device)) # funzione per calolo della pendenza m def slope(self, fdistance): From 90e81bc35d2a041339f43adeb9c819c7ec39a369 Mon Sep 17 00:00:00 2001 From: dkarlov Date: Sat, 19 Jul 2025 20:54:15 +0100 Subject: [PATCH 2/2] Script now recognizes versions of ACEMD 3 and 4 --- suMD | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/suMD b/suMD index 9bd7174..abf4017 100644 --- a/suMD +++ b/suMD @@ -358,8 +358,21 @@ class suMD: # funzione per lancio di acemd dove si esplicitano il device e quale input utilizzare def Run_Acemd(self, n_device, Input_run): - print('{} --device {} {} > suMD-Simulation_step.log'.format(self.acemd, n_device, Input_run)) - os.system('{} --input {} --device {} > suMD-Simulation_step.log'.format(self.acemd, Input_run, n_device)) + + # acemd version check + result = subprocess.run([self.acemd, '--version'], stdout=subprocess.PIPE).stdout.split() + if result[0] != 'ACEMD': + raise RuntimeError(f'Check of ACEMD version: {self.acemd} --version yield the following output: {result}') + else: + if result[1].split('.')[0] == '3': + print('{} --device {} {} > suMD-Simulation_step.log'.format(self.acemd, n_device, Input_run)) + os.system('{} --device {} {} > suMD-Simulation_step.log'.format(self.acemd, Input_run, n_device)) + elif result[1].split('.')[0] == '4': + print('{} --input {} --device {} > suMD-Simulation_step.log'.format(self.acemd, n_device, Input_run)) + os.system('{} --input {} --device {} > suMD-Simulation_step.log'.format(self.acemd, Input_run, n_device)) + else: + raise NotImplementedError(f'ACEMD version {result[1]} is not supported yet') + # funzione per calolo della pendenza m def slope(self, fdistance):