Beispiel #1
0
 def parseRow():
     atom = yield regex(r'\s*[a-zA-Z.]*')
     yield whitespace.many()
     x = yield floatParser
     yield whitespace.many()
     y = yield floatParser
     yield whitespace.many()
     z = yield floatParser
     return np.array([x, y, z]), atom.strip()
Beispiel #2
0
 def parseRow():
     atom = yield regex(r'\s*[a-zA-Z0-9.]*')
     try:
         atomNumber = int(atom)
         atom = atom_names[atomNumber]
     except ValueError:
         pass
     yield whitespace.many()
     x = yield floatParser
     yield whitespace.many()
     y = yield floatParser
     yield whitespace.many()
     z = yield floatParser
     return np.array([x, y, z]), atom.strip()
Beispiel #3
0
 def parseContent():
     yield parseHeader.optional()
     table = yield parseRow.many()
     yield whitespace.many()
     atomCoords = [a[0] for a in table]
     atomNames = [a[1] for a in table]
     return np.array(atomCoords), np.array(atomNames)
Beispiel #4
0
def partsParser():
    rangeOrNumber = whitespace.many() >> (rangeParser | uintToList)
    rangesList = yield rangeOrNumber.sep_by(string(','))
    return flatten(rangesList)
Beispiel #5
0
def rangeParser():
    lower = yield uintParser
    yield whitespace.many() >> string('-') >> whitespace.many()
    upper = yield uintParser
    return list(range(lower, upper + 1))