Esempio n. 1
0
def getCoordsFromInp( oldInput ):
    oldFile = open(oldInput, 'r')
    line = oldFile.readline()
    
    #route section
    while not isBlankLine(line):
        line = oldFile.readline()
        
    line = oldFile.readline()
    #comment
    while not isBlankLine(line):
        line = oldFile.readline()
        
    line = oldFile.readline() #charges and multiplicity
    line = oldFile.readline()
    
    coords = []
    while not isBlankLine(line):
        
        lineSpl = line.split()
        coordInd = floatInList(lineSpl)[-3:]
        newCoords = [ float(lineSpl[c]) for c in coordInd]
        coords.append(newCoords)
        line = oldFile.readline()
    
    oldFile.close()
    
    return coords
def getCoordInd(lineSpl):
    floatInd = floatInList(lineSpl)

    contInd = [floatInd[0]]
    lastElement = floatInd[0]

    for ind in floatInd[1:]:
        if ind - lastElement == 1:
            contInd.append(ind)
        else:
            break
        lastElement = ind

    return contInd[-3:]
Esempio n. 3
0
def writeNewInput ( oldInput, newCoords, newInputName, modredundantLines ):
    oldFile = open(oldInput, 'r')
    beginning = ""
    line = oldFile.readline()
    destiny = open(newInputName, 'w')
    
    #route section
    while not isBlankLine(line):
        beginning += line
        line = oldFile.readline()
        
    beginning += line
    line = oldFile.readline()
    #comment
    while not isBlankLine(line):
        beginning += line
        line = oldFile.readline()
        
    beginning += line
    line = oldFile.readline()
    
    beginning += line
    destiny.write(beginning)
    for coord in newCoords:
        line = oldFile.readline()
        lineSpl = line.split()
        coordInd = floatInList(lineSpl)[-3:]
        for ci, crd in zip(coordInd, coord):
            lineSpl[ci] = str(crd)
        destiny.write("\t".join(lineSpl)+"\n")
        
    line = oldFile.readline()
    nonBondParameters = False
    while line:
        if "NonBon" in line and modredundantLines:
            destiny.write(modredundantLines)
            destiny.write("\n\n")
            nonBondParameters = True
        
        destiny.write(line)
        line = oldFile.readline()
        
    if not nonBondParameters:
        destiny.write(modredundantLines)
        destiny.write("\n")
    
    destiny.close()
    oldFile.close()
Esempio n. 4
0
def writeNewInput(oldInput, newCoords, newInputName, indexes):
    oldFile = open(oldInput, 'r')
    beginning = ""
    line = oldFile.readline()
    destiny = open(newInputName, 'w')

    #route section
    while not isBlankLine(line):
        beginning += line
        line = oldFile.readline()

    beginning += line
    line = oldFile.readline()
    #comment
    while not isBlankLine(line):
        beginning += line
        line = oldFile.readline()

    #charge and multiplicity
    beginning += line
    line = oldFile.readline()

    beginning += line
    destiny.write(beginning)
    fullCoordsIndex = 0
    newCoordsIndex = 0
    while not isBlankLine(line):
        line = oldFile.readline()
        lineSpl = line.split()
        coordInd = floatInList(lineSpl)[-3:]

        if fullCoordsIndex in indexes:
            coord = newCoords[newCoordsIndex]
            for ci, crd in zip(coordInd, coord):
                lineSpl[ci] = str(crd)
            newCoordsIndex += 1

        destiny.write("\t".join(lineSpl) + "\n")
        fullCoordsIndex += 1

    line = oldFile.readline()
    while line:
        destiny.write(line)
        line = oldFile.readline()

    destiny.close()
    oldFile.close()
Esempio n. 5
0
def writeNewInput(oldInput, newCoords, newInputName):
    oldFile = open(oldInput, 'r')
    beginning = ""
    line = oldFile.readline()
    destiny = open(newInputName, 'w')

    #route section
    while not isBlankLine(line):
        beginning += line
        line = oldFile.readline()

    beginning += line
    line = oldFile.readline()
    #comment
    while not isBlankLine(line):
        beginning += line
        line = oldFile.readline()

    beginning += line
    line = oldFile.readline()

    beginning += line
    destiny.write(beginning)
    for coord in newCoords:
        line = oldFile.readline()
        lineSpl = line.split()
        coordInd = floatInList(lineSpl)[-3:]
        for ci, crd in zip(coordInd, coord):
            lineSpl[ci] = str(crd)
        destiny.write("\t".join(lineSpl) + "\n")

    line = oldFile.readline()
    while line:
        destiny.write(line)
        line = oldFile.readline()

    destiny.close()
    oldFile.close()
Esempio n. 6
0
def getFrozenIndexes(oldInput):
    oldFile = open(oldInput, 'r')
    line = oldFile.readline()

    #route section
    while not isBlankLine(line):
        line = oldFile.readline()

    line = oldFile.readline()
    #comment
    while not isBlankLine(line):
        line = oldFile.readline()

    line = oldFile.readline()  #charges and multiplicity
    line = oldFile.readline()

    indexes = []
    ind = 0
    coords = []
    elements = []
    while not isBlankLine(line):

        lineSpl = line.split()
        if lineSpl[1] == "-1":
            indexes.append(ind)

        coordInd = floatInList(lineSpl)[-3:]
        newCoords = [float(lineSpl[c]) for c in coordInd]
        coords.append(newCoords)
        elements.append(lineSpl[0])

        line = oldFile.readline()
        ind += 1

    oldFile.close()

    return indexes, coords, elements
Esempio n. 7
0
def readHighLayerFromInput(oldInput):
    oldFile = open(oldInput, 'r')
    line = oldFile.readline()

    #route section
    while not isBlankLine(line):
        line = oldFile.readline()

    line = oldFile.readline()
    #comment
    while not isBlankLine(line):
        line = oldFile.readline()

    line = oldFile.readline()  #charges and multiplicity
    line = oldFile.readline()

    coords = []
    elements = []
    while not isBlankLine(line):

        lineSpl = line.split()
        coordInd = floatInList(lineSpl)[-3:]
        newCoords = [float(lineSpl[c]) for c in coordInd]

        layerInd = lineSpl[coordInd[-1] + 1]

        if "H" == layerInd.upper():
            coords.append(newCoords)
            element = lineSpl[0][0]
            elements.append(element)

        line = oldFile.readline()

    oldFile.close()

    return elements, coords