Ejemplo n.º 1
0
def readfromtxt(mol, txt):
    # print('!!!!', filename)
    globs = globalvars()
    en_dict = globs.endict()
    mol.graph = []
    for line in txt:
        line_split = line.split()
        if len(line_split) == 4 and line_split[0]:
            # this looks for unique atom IDs in files
            lm = re.search(r'\d+$', line_split[0])
            # if the string ends in digits m will be a Match object, or None otherwise.
            if lm is not None:
                symb = re.sub('\d+', '', line_split[0])
                # number = lm.group()
                # # print('sym and number ' +str(symb) + ' ' + str(number))
                # globs = globalvars()
                atom = atom3D(symb, [float(line_split[1]), float(line_split[2]), float(line_split[3])],
                              name=line_split[0])
            elif line_split[0] in en_dict.keys():
                atom = atom3D(line_split[0], [float(line_split[1]), float(line_split[2]), float(line_split[3])])
            else:
                print('cannot find atom type')
                sys.exit()
            mol.addAtom(atom)
    return mol
Ejemplo n.º 2
0
def readfromtxt(mol, txt):
    # print('!!!!', filename)
    globs = globalvars()
    en_dict = globs.endict()
    mol.graph = []
    for line in txt:
        line_split = line.split()
        if len(line_split) == 4 and line_split[0]:
            # this looks for unique atom IDs in files
            lm = re.search(r'\d+$', line_split[0])
            # if the string ends in digits m will be a Match object, or None otherwise.
            if lm is not None:
                symb = re.sub('\d+', '', line_split[0])
                # number = lm.group()
                # # print('sym and number ' +str(symb) + ' ' + str(number))
                # globs = globalvars()
                atom = atom3D(symb, [
                    float(line_split[1]),
                    float(line_split[2]),
                    float(line_split[3])
                ],
                              name=line_split[0])
            elif line_split[0] in list(en_dict.keys()):
                atom = atom3D(line_split[0], [
                    float(line_split[1]),
                    float(line_split[2]),
                    float(line_split[3])
                ])
            else:
                print('cannot find atom type')
                sys.exit()
            mol.addAtom(atom)
    return mol
Ejemplo n.º 3
0
def pad_mol(mol,target_atoms):
    ## adds placeholder atoms 
    ## with zero nuclear charge
    ## located at the origin
    ## in order to get consistent size
    ## coulomb matrix
    this_natoms = mol.natoms
    blank_atom = atom3D(Sym='X') # placeholder type
    blank_atom.frozen=False
    safe_stop = False
    counter = 0;
    while this_natoms < target_atoms and not safe_stop:
        mol.addAtom(blank_atom)
        this_natoms = mol.natoms
        counter +=1
        if counter > target_atoms:
            safe_stop = True
            print('error padding mol')
    return mol
Ejemplo n.º 4
0
def pad_mol(mol, target_atoms):
    ## adds placeholder atoms
    ## with zero nuclear charge
    ## located at the origin
    ## in order to get consistent size
    ## coulomb matrix
    this_natoms = mol.natoms
    blank_atom = atom3D(Sym='X')  # placeholder type
    blank_atom.frozen = False
    safe_stop = False
    counter = 0
    while this_natoms < target_atoms and not safe_stop:
        mol.addAtom(blank_atom)
        this_natoms = mol.natoms
        counter += 1
        if counter > target_atoms:
            safe_stop = True
            print('error padding mol')
    return mol