Skip to content

Commit

Permalink
update the output
Browse files Browse the repository at this point in the history
  • Loading branch information
SangniXun committed Aug 6, 2024
1 parent 29735c3 commit 9a1945a
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions autosolvate/autoMCPB.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn"
]

cheat_metal = {1:'CU',2:'Fe',3:'Fe',4: 'Mn',}
cheat_metal = {1:'CU',2:'Fe',3:'Fe',4: 'Mn'}

valence_electrons = {
'H': 1,
Expand Down Expand Up @@ -184,7 +184,7 @@ def metal_list(self):
metal_list = complex_mol.findMetal()
self.cheat_metal = None
if len(metal_list) > 1:
print("Error: autosolvate can't deal with multi-metal systems")
raise TypeError("Error: autosolvate can't deal with multi-metal systems")
sys.exit()
elif len(metal_list) == 0:
print('Warning: There is no metal in the xyz file or molsimplify can not support this metal.')
Expand All @@ -197,16 +197,17 @@ def metal_list(self):
if atomtype in metals:
metalall.append(atomtype)
if len(metalall) == 0:
print('Error: There is no metal in the xyz file')
raise TypeError('Error: There is no metal in the xyz file')
sys.exit()
elif len(metalall) > 1:
print("Error: autosolvate can't deal with multi-metal systems")
raise TypeError("Error: autosolvate can't deal with multi-metal systems")
sys.exit()
elif len(metalall) == 1:
print('Find one metal atom',metalall[0])
self.metal_name = metalall[0].upper()
self.cheat_metal = metalall[0].upper()
prefix = os.path.splitext(self.xyzfile)[0]
print('Use', cheat_metal[int(self.metal_charge)], 'instead of', metalall[0],'to generate ligand files')
### generate cheat_metal_xyz ###
cheat_metalxyz = open(prefix + '_cheat.xyz','w')
cheat_metalname = cheat_metal[int(self.metal_charge)]
Expand All @@ -219,7 +220,7 @@ def metal_list(self):
atomtype = str.capitalize(line.split()[0]).strip()
if atomtype.upper() == self.metal_name:
new_string = line.replace(atomtype,cheat_metalname.capitalize())
print(new_string)
# print(new_string)
cheat_metalxyz.write(new_string)
else:
cheat_metalxyz.write(line)
Expand All @@ -228,12 +229,12 @@ def metal_list(self):
self.xyzfile = prefix + '_cheat.xyz'
print('now,the xyzfile is ', self.xyzfile)
cheat_complex_mol = mol3D()
print(self.xyzfile)
# print(self.xyzfile)
cheat_complex_mol.readfromxyz(self.xyzfile)
metal_list = cheat_complex_mol.findMetal()
self.metal_ID = metal_list[0]
self.metal_name = cheat_metalname.upper()
print(self.metal_name)
# print(self.metal_name)
self.coordinates_reader_xyz()

elif len(metal_list) == 1:
Expand Down Expand Up @@ -377,7 +378,7 @@ def check_radical(self, ligandxyz): #### this code is for checking the radical l
mol = [mol for mol in suppl][0]

if mol == None:
print('Error: RDKit can not read the ligand, please check the ligand',ligandxyz)
raise TypeError('Error: RDKit can not read the ligand, please check the ligand',ligandxyz)
sys.exit()
else:
# print('In ',ligandxyz.split('.xyz')[0],':')
Expand Down Expand Up @@ -878,6 +879,10 @@ def change_thecheat_atom(self):
finalpdb.write(line)
finalpdb.close()

pdbin = prefix + '_final.pdb'
xyzout = prefix + '_final.xyz'
write(xyzout, read(pdbin))

### generate real info file ###

infofile = prefix + '.info'
Expand Down Expand Up @@ -926,6 +931,8 @@ def change_thecheat_atom(self):
else:
finalMCPBinput.write(line)
finalMCPBinput.close()



def run_MCPB_1(self):
if self.round in ['1']:
Expand Down

0 comments on commit 9a1945a

Please sign in to comment.