diff --git a/autosolvate/multicomponent.py b/autosolvate/multicomponent.py index de8541f..1e11ba8 100644 --- a/autosolvate/multicomponent.py +++ b/autosolvate/multicomponent.py @@ -190,8 +190,8 @@ def __init__(self, folder = WORKING_DIR, cube_size = 54, closeness = 2.0, charge def add_solute(self, xyzfile:str, name="", residue_name="", charge=0, spinmult=1, number = 1, **kwargs): #use the first three letters of the xyzfile name as the residue name - if not residue_name and len(xyzfile.split(".")[0]) >= 3: - residue_name = xyzfile.split(".")[0][:3].upper() + if not residue_name and len(xyzfile.split(".")[0].split("/")[-1]) >= 3: + residue_name = xyzfile.split(".")[0].split("/")[-1][:3].upper() molecule = Molecule(xyzfile, charge=charge, multiplicity=spinmult, folder = self.folder, name = name, residue_name=residue_name) @@ -212,8 +212,9 @@ def add_solute(self, xyzfile:str, name="", residue_name="", charge=0, spinmult=1 def add_solvent(self, xyzfile:str, name="", residue_name="", charge=0, spinmult=1, number = 200, **kwargs): #use the first three letters of the xyzfile name as the residue name - if not residue_name and len(xyzfile.split(".")[0]) >= 3: - residue_name = xyzfile.split(".")[0][:3].upper() + if not residue_name and len(xyzfile.split(".")[0].split("/")[-1]) >= 3: + #get the file name from the absolute path + residue_name = xyzfile.split(".")[0].split("/")[-1][:3].upper() molecule = Molecule(xyzfile, charge=charge, multiplicity=spinmult, folder = self.folder, name = name, residue_name=residue_name)