コード例 #1
0
ファイル: inp2scan.py プロジェクト: chemiczny/ONIOM_assistant
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
コード例 #2
0
def readHighLayerIndexesFromInput(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 = []
    actualIndex = 0
    while not isBlankLine(line):

        lineSpl = line.split()
        coordInd = getCoordInd(lineSpl)

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

        if "H" == layerInd.upper():
            indexes.append(actualIndex)

        line = oldFile.readline()
        actualIndex += 1

    oldFile.close()

    return indexes
コード例 #3
0
ファイル: inp2scan.py プロジェクト: chemiczny/ONIOM_assistant
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()
コード例 #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()
コード例 #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()
コード例 #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
コード例 #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