Exemple #1
0
def _logParser(fname):
    import re
    unknownres_regex = re.compile('Unknown residue:\s+(\w+)')
    missingparam_regex = re.compile('For atom: (.*) Could not find vdW \(or other\) parameters for type:\s+(\w+)')
    missingtorsion_regex = re.compile('No torsion terms for\s+(.*)$')
    missingbond_regex = re.compile('Could not find bond parameter for:\s+(.*)$')
    missingangle_regex = re.compile('Could not find angle parameter:\s+(.*)$')
    missingatomtype_regex = re.compile('FATAL:\s+Atom (.*) does not have a type')

    unknownres = []
    missingparam = []
    missingtorsion = []
    missingbond = []
    missingangle = []
    missingatomtype = []
    with open(fname, 'r') as f:
        for line in f:
            if unknownres_regex.search(line):
                unknownres.append(unknownres_regex.findall(line)[0])
            if missingparam_regex.search(line):
                missingparam.append(missingparam_regex.findall(line)[0])
            if missingtorsion_regex.search(line):
                missingtorsion.append(missingtorsion_regex.findall(line)[0])
            if missingbond_regex.search(line):
                missingbond.append(missingbond_regex.findall(line)[0])
            if missingangle_regex.search(line):
                missingangle.append(missingangle_regex.findall(line)[0])
            if missingatomtype_regex.search(line):
                missingatomtype.append(missingatomtype_regex.findall(line)[0])

    errors = []
    if len(unknownres):
        errors.append(UnknownResidueError('Unknown residue(s) {} found in the input structure. '
                                          'You are either missing a topology definition for the residue or you need to '
                                          'rename it to the correct residue name'.format(np.unique(unknownres))))
    if len(missingparam):
        errors.append(MissingParameterError('Missing parameters for atom {} and type {}'.format(missingparam, missingparam)))
    if len(missingtorsion):
        errors.append(MissingTorsionError('Missing torsion terms for {}'.format(missingtorsion)))
    if len(missingbond):
        errors.append(MissingBondError('Missing bond parameters for {}'.format(missingbond)))
    if len(missingangle):
        errors.append(MissingAngleError('Missing angle parameters for {}'.format(missingangle)))
    if len(missingatomtype):
        errors.append(MissingAtomTypeError('Missing atom type for {}'.format(missingatomtype)))

    return errors
Exemple #2
0
def _logParser(fname):
    import re

    unknownres_regex = re.compile("Unknown residue:\s+(\w+)")
    missingparam_regex = re.compile(
        "For atom: (.*) Could not find vdW \(or other\) parameters for type:\s+(\w+)"
    )
    missingtorsion_regex = re.compile("No torsion terms for\s+(.*)$")
    missingbond_regex = re.compile(
        "Could not find bond parameter for:\s+(.*)$")
    missingangle_regex = re.compile("Could not find angle parameter:\s+(.*)$")
    missingatomtype_regex = re.compile(
        "FATAL:\s+Atom (.*) does not have a type")

    unknownres = []
    missingparam = []
    missingtorsion = []
    missingbond = []
    missingangle = []
    missingatomtype = []
    with open(fname, "r") as f:
        for line in f:
            if unknownres_regex.search(line):
                unknownres.append(unknownres_regex.findall(line)[0])
            if missingparam_regex.search(line):
                missingparam.append(missingparam_regex.findall(line)[0])
            if missingtorsion_regex.search(line):
                missingtorsion.append(missingtorsion_regex.findall(line)[0])
            if missingbond_regex.search(line):
                missingbond.append(missingbond_regex.findall(line)[0])
            if missingangle_regex.search(line):
                missingangle.append(missingangle_regex.findall(line)[0])
            if missingatomtype_regex.search(line):
                missingatomtype.append(missingatomtype_regex.findall(line)[0])

    errors = []
    if len(unknownres):
        errors.append(
            UnknownResidueError(
                f"Unknown residue(s) {np.unique(unknownres)} found in the input structure. "
                "You are either missing a topology definition for the residue or you need to "
                "rename it to the correct residue name"))
    if len(missingparam):
        errors.append(
            MissingParameterError(
                f"Missing parameters for atom {missingparam} and type {missingparam}"
            ))
    if len(missingtorsion):
        errors.append(
            MissingTorsionError(f"Missing torsion terms for {missingtorsion}"))
    if len(missingbond):
        errors.append(
            MissingBondError(f"Missing bond parameters for {missingbond}"))
    if len(missingangle):
        errors.append(
            MissingAngleError(f"Missing angle parameters for {missingangle}"))
    if len(missingatomtype):
        errors.append(
            MissingAtomTypeError(f"Missing atom type for {missingatomtype}"))

    return errors