import hashlib


def calcChecksum(filepath):
    """ Calculate MD5 of relevant information
        Returns tuple of filename and calculated hash
    """
    with open(filepath, "r") as fil:
        cnt = fil.readlines()
        relinfo = []
        for line in cnt:
            atm = line[12:16].rstrip().lstrip()
            altloc = line[16]
            if (atm == "CA"):
                if (altloc == ' '):
                    AA = line[17:20].rstrip().lstrip()
                    relinfo.append(AA)
                else:
                    return None
        return (filepath, hashlib.md5("".join(relinfo).encode("utf-8")).hexdigest())