def main():
    print(
        'This program regenerates the `%s` database using the "Chemical Component '
        % DBNAME)
    print(
        'Dictionary" and "Protonation Variants Dictionary" from http://www.wwpdb.org/data/ccd'
    )

    if len(sys.argv) > 1 and sys.argv[1] == '--download':
        print('Downloading newest CCD files ...\n')
        download_ccd()
    else:
        print(
            'Using cached download (run with "--download" to download a new version)'
        )

    residues = read_ccd()

    db = utils.CompressedJsonDbm(DBNAME, 'n')
    db['__FIELDS__'] = {'ATOMFIELDS': ATOMFIELDS, 'RESFIELDS': RESFIELDS}

    for resname, data in residues:
        store_residue(resname, data, db)

    print('\nCreated db "%s" (%d records)' % (DBNAME, len(db)))
    db.close()
        self.index = self.hostdb['__FIELDS__']['RESFIELDS'].index(keyname)

    def __repr__(self):
        return '<Chemical component dictionary: "%s" entries>' % self.keyname

    def __getitem__(self, item):
        return self.hostdb[item][self.index]

    __contains__ = utils.Alias('hostdb.__contains__')

    def keys(self):
        for key in self.hostdb.keys():
            if key == '__FIELDS__':
                continue
            yield key

    def items(self):
        for key in self:
            yield key, self[key]

    __iter__ = keys


# This is a very big dict, so we load it as a compressed database
_bondfilename = os.path.join(PACKAGEPATH, '_static_data', 'chemical_components')
CCD_DATABASE = utils.CompressedJsonDbm(_bondfilename, 'r', dbm=utils.ReadOnlyDumb)
RESIDUE_BONDS = _DatabaseEntry(CCD_DATABASE, 'bonds')
RESIDUE_ATOMS = _DatabaseEntry(CCD_DATABASE, 'atoms')
RESIDUE_CCD_NAMES = _DatabaseEntry(CCD_DATABASE, 'name')
RESIDUE_CCD_TYPES = _DatabaseEntry(CCD_DATABASE, 'type')
Example #3
0
                          ASN="N",
                          PRO="P",
                          GLN="Q",
                          ARG="R",
                          SER="S",
                          THR="T",
                          VAL="V",
                          TRP="W",
                          XAA="X",
                          TYR="Y",
                          GLX="Z")

# This is a very big dict, so we load it as a compressed database
_bondfilename = os.path.join(PACKAGEPATH, '_static_data/residue_bonds')
RESIDUE_BONDS = utils.CompressedJsonDbm(_bondfilename,
                                        'r',
                                        dbm=utils.ReadOnlyDumb)

AMINO_NAMES = {
    "ALA": "Alanine",
    "ARG": "Arginine",
    "ASN": "Asparagine",
    "ASP": "Aspartic acid",
    "ASX": "ASP/ASN ambiguous",
    "CYS": "Cysteine",
    "GLN": "Glutamine",
    "GLU": "Glutamic acid",
    "GLX": "GLU/GLN ambiguous",
    "GLY": "Glycine",
    "HIS": "Histidine",
    "HIE": "Histidine epsilon tautomer",