def define_tdoc_struct_ref_seq_dif():
    table_name='struct_ref_seq_dif'
    comment='Table that provides a mechanism for indicating and annotating point differences in the alignment of the macromolecular sequence with the reference sequence; mmCIF category: struct_ref_seq_dif'

    column_defs = [
        Column.define(
            "pdbx_ordinal",
            builtin_types.int8,
            comment='A unique identifier for a record in the table',
            nullok=False
        ),
        Column.define(
            "align_id",
            builtin_types.text,
            comment='A pointer to the alignment in the struct_ref_seq table',
            nullok=False
        ),
        Column.define(
            "seq_num",
            builtin_types.int8,
            comment='The position in the macromolecular sequence with the point difference',
            nullok=True
        ),
        Column.define(
            "mon_id",
            builtin_types.text,
            comment='The monomer type in the macromolecular sequence with the point difference',
            nullok=True
        ),
        Column.define(
            "db_mon_id",
            builtin_types.text,
            comment='The monomer type in the reference database sequence with the point difference',
            nullok=True
        ),
        Column.define(
            "details",
            builtin_types.text,
            comment='Additional details about the special aspects of the point difference',
            nullok=True
        ),
        Column.define(
            "structure_id",
            builtin_types.text,
            comment='Structure identifier',
            nullok=False
        ),
        # HT: to use for Chaise
        Column.define(
            "Align_RID",
            builtin_types.text,
            comment='Identifier to the alignment RID',
            nullok=False
        )
    ]
    key_defs = [
        Key.define(["structure_id", "pdbx_ordinal"], constraint_names=[["PDB", "struct_ref_seq_dif_primary_key"]] ),
        Key.define(["RID"], constraint_names=[["PDB", "struct_ref_seq_dif_RID_key"]] )
    ]

    # @brinda: add fk pseudo-definition
    fkey_defs = [
        # HT: it own fk to Entry table
        ForeignKey.define(["structure_id"], "PDB", "entry", ["id"],
                          constraint_names=[["PDB", "struct_ref_seq_dif_structure_id_fkey"]],
                          on_update="CASCADE",
                          on_delete="NO ACTION"
        ),
        # HT: In annotation, apply domain_filter to filter the RID list by constraining structure_id        
        ForeignKey.define(["Align_RID", "structure_id", "align_id"], "PDB", "struct_ref_seq", ["RID", "structure_id", "align_id"],
                          constraint_names=[["PDB", "struct_ref_seq_dif_struct_ref_seq_combo1_fkey"]],
                          on_update="CASCADE",
                          on_delete="NO ACTION"
        ),
        ForeignKey.define(["details"], "Vocab", "struct_ref_seq_dif_details", ["Name"],
                          constraint_names=[ ["Vocab", "struct_ref_seq_dif_details_fkey"] ],
                          on_update="CASCADE",
                          on_delete="NO ACTION"
        )
    ]

    table_def = Table.define(
        table_name,
        column_defs,
        key_defs=key_defs,
        fkey_defs=fkey_defs,
        comment=comment,
        provide_system=True
    )

    return table_def
Example #2
0
config.acls.update(acls)
catalog.applyCatalogConfig(config)

for fname in monarch_files:
    print('Importing {fname}...'.format(fname=fname))
    tname = os.path.splitext(os.path.basename(fname))[0]

    pk = 'pk'
    col_defs = [Column.define(pk, builtin_types.int8)]
    key_defs = [Key.define([pk])]

    with open(fname) as tsvfile:
        reader = csv.DictReader(tsvfile, delimiter='\t')
        for cname in reader.fieldnames:
            col_defs.append(Column.define(cname, builtin_types.text))
        tab_def = Table.define(tname, column_defs=col_defs, key_defs=key_defs, acls=acls, provide_system=False)

        print('Creating table {tname}...'.format(tname=tname))
        try:
            public.create_table(catalog, tab_def)
        except HTTPError as e:
            print(e)
            print(e.response.text)
            exit(1)

        # Now to import data...
        pb = catalog.getPathBuilder()
        table = pb.public.tables[tname]

        print('Importing data into {tname}'.format(tname=tname))
        print(table.uri)
def define_tdoc_struct_ref_seq():
    table_name='struct_ref_seq'
    comment='Table that provides a mechanism for indicating and annotating the regions of alignment between the macromolecular sequence of an entity in the integrative model and the sequence in the reference database; mmCIF category: struct_ref_seq'

    column_defs = [
        Column.define(
            "align_id",
            builtin_types.text,
            comment='A unique identifier for a record in the table',
            nullok=False
        ),
        Column.define(
            "ref_id",
            builtin_types.text,
            comment='A pointer to the reference in the struct_ref table',
            nullok=False
        ),
        Column.define(
            "db_align_beg",
            builtin_types.int8,
            comment='The sequence position in the referenced database entry at which the alignment begins',
            nullok=False
        ),
        Column.define(
            "db_align_end",
            builtin_types.int8,
            comment='The sequence position in the referenced database entry at which the alignment ends',
            nullok=False
        ),
        Column.define(
            "seq_align_beg",
            builtin_types.int8,
            comment='The position in the macromolecular entity sequence at which the alignment begins',
            nullok=False
        ),
        Column.define(
            "seq_align_end",
            builtin_types.int8,
            comment='The position in the macromolecular entity sequence at which the alignment ends',
            nullok=False
        ),
        Column.define(
            "details",
            builtin_types.text,
            comment='Additional details about the alignment',
            nullok=True
        ),
        Column.define(
            "structure_id",
            builtin_types.text,
            comment='Structure identifier',
            nullok=False
        ),
        # HT: to use for Chaise
        Column.define(
            "Ref_RID",
            builtin_types.text,
            comment='Identifier to the reference RID',
            nullok=False
        )
    ]
    key_defs = [
        Key.define(["structure_id", "align_id"], constraint_names=[["PDB", "struct_ref_seq_primary_key"]] ),
        Key.define(["RID"], constraint_names=[["PDB", "struct_ref_seq_RID_key"]] ),
        Key.define(["RID", "structure_id", "align_id"], constraint_names=[["PDB", "struct_ref_seq_combo1_key"]] )
    ]

    # @brinda: add fk pseudo-definition
    fkey_defs = [
        # HT: it own fk to Entry table
        ForeignKey.define(["structure_id"], "PDB", "entry", ["id"],
                          constraint_names=[["PDB", "struct_ref_seq_structure_id_fkey"]],
                          on_update="CASCADE",
                          on_delete="NO ACTION"
        ),
        # HT: In annotation, apply domain_filter to filter the RID list by constraining structure_id        
        ForeignKey.define(["Ref_RID", "structure_id", "ref_id"], "PDB", "struct_ref", ["RID", "structure_id", "id"],
                          constraint_names=[["PDB", "struct_ref_seq_struct_ref_combo1_fkey"]],
                          on_update="CASCADE",
                          on_delete="NO ACTION"
        )
    ]

    table_def = Table.define(
        table_name,
        column_defs,
        key_defs=key_defs,
        fkey_defs=fkey_defs,
        comment=comment,
        provide_system=True
    )

    return table_def
def define_tdoc_ihm_derived_dihedral_restraint():
    table_name = 'ihm_derived_dihedral_restraint'
    comment = 'Details of dihedral restraints used in integrative modeling; can be uploaded as CSV/TSV file above; mmCIF category: ihm_derived_dihedral_restraint'

    column_defs = [
        Column.define("id",
                      builtin_types.int8,
                      comment='An identifier for the dihedral restraint',
                      nullok=False),
        Column.define("group_id",
                      builtin_types.int8,
                      comment='An identifier to group the dihedral restraints',
                      nullok=True),
        Column.define(
            "feature_id_1",
            builtin_types.int8,
            comment=
            'The feature identifier for the first partner in the dihedral restraint',
            nullok=False),
        Column.define(
            "feature_id_2",
            builtin_types.int8,
            comment=
            'The feature identifier for the second partner in the dihedral restraint',
            nullok=False),
        Column.define(
            "feature_id_3",
            builtin_types.int8,
            comment=
            'The feature identifier for the third partner in the dihedral restraint',
            nullok=False),
        Column.define(
            "feature_id_4",
            builtin_types.int8,
            comment=
            'The feature identifier for the fourth partner in the dihedral restraint',
            nullok=False),
        Column.define(
            "group_conditionality",
            builtin_types.text,
            comment=
            'If a group of dihedrals are restrained together, this data item defines the conditionality based on which the restraint is applied in the modeling',
            nullok=True),
        Column.define(
            "dihedral_lower_limit",
            builtin_types.float8,
            comment=
            'The lower limit to the threshold applied to this dihedral restraint',
            nullok=True),
        Column.define(
            "dihedral_upper_limit",
            builtin_types.float8,
            comment=
            'The upper limit to the threshold applied to this dihedral restraint',
            nullok=True),
        Column.define(
            "dihedral_lower_limit_esd",
            builtin_types.float8,
            comment=
            'The estimated standard deviation of the lower limit dihedral threshold applied',
            nullok=True),
        Column.define(
            "dihedral_upper_limit_esd",
            builtin_types.float8,
            comment=
            'The estimated standard deviation of the upper limit dihedral threshold applied',
            nullok=True),
        Column.define(
            "probability",
            builtin_types.float8,
            comment='The probability that the dihedral restraint is correct',
            nullok=True),
        Column.define("restraint_type",
                      builtin_types.text,
                      comment='The type of dihedral restraint applied',
                      nullok=False),
        Column.define(
            "dihedral_threshold_mean",
            builtin_types.float8,
            comment='The dihedral threshold mean applied to the restraint',
            nullok=True),
        Column.define(
            "dihedral_threshold_mean_esd",
            builtin_types.float8,
            comment=
            'The estimated standard deviation of the dihedral threshold mean applied to the restraint',
            nullok=True),
        Column.define(
            "dataset_list_id",
            builtin_types.int8,
            comment=
            'Identifier to the input data from which the dihedral restraint is derived',
            nullok=False),
        Column.define(
            "Entry_Related_File",
            builtin_types.text,
            comment=
            'A reference to the uploaded restraint file in the table Entry_Related_File.id.',
            nullok=True),
        Column.define("structure_id",
                      builtin_types.text,
                      comment='Structure identifier',
                      nullok=False),
        # HT: to use for Chaise
        Column.define("Feature_Id_1_RID",
                      builtin_types.text,
                      comment='Identifier to the feature 1 RID',
                      nullok=False),
        Column.define("Feature_Id_2_RID",
                      builtin_types.text,
                      comment='Identifier to the feature 2 RID',
                      nullok=False),
        Column.define("Feature_Id_3_RID",
                      builtin_types.text,
                      comment='Identifier to the feature 3 RID',
                      nullok=False),
        Column.define("Feature_Id_4_RID",
                      builtin_types.text,
                      comment='Identifier to the feature 4 RID',
                      nullok=False),
        Column.define("Dataset_List_RID",
                      builtin_types.text,
                      comment='Identifier to the dataset list RID',
                      nullok=False)
    ]
    #BV: This is a leaf table; so no combo1/combo2 keys required
    key_defs = [
        Key.define(["structure_id", "id"],
                   constraint_names=[[
                       "PDB", "ihm_derived_dihedral_restraint_primary_key"
                   ]]),
        Key.define(["RID"],
                   constraint_names=[[
                       "PDB", "ihm_derived_dihedral_restraint_RID_key"
                   ]]),
    ]

    # @brinda: add fk pseudo-definition
    fkey_defs = [
        # HT: it own fk to Entry table
        ForeignKey.define(
            ["structure_id"],
            "PDB",
            "entry", ["id"],
            constraint_names=[[
                "PDB", "ihm_derived_dihedral_restraint_structure_id_fkey"
            ]],
            on_update="CASCADE",
            on_delete="NO ACTION"),
        # HT: In annotation, apply domain_filter to filter the RID list by constraining structure_id
        ForeignKey.define(
            ["Feature_Id_1_RID", "structure_id", "feature_id_1"],
            "PDB",
            "ihm_feature_list", ["RID", "structure_id", "feature_id"],
            constraint_names=[[
                "PDB",
                "ihm_derived_dihedral_restraint_ihm_feature_list_1_combo1_fkey"
            ]],
            on_update="CASCADE",
            on_delete="NO ACTION"),
        ForeignKey.define(
            ["Feature_Id_2_RID", "structure_id", "feature_id_2"],
            "PDB",
            "ihm_feature_list", ["RID", "structure_id", "feature_id"],
            constraint_names=[[
                "PDB",
                "ihm_derived_dihedral_restraint_ihm_feature_list_2_combo1_fkey"
            ]],
            on_update="CASCADE",
            on_delete="NO ACTION"),
        ForeignKey.define(
            ["Feature_Id_3_RID", "structure_id", "feature_id_3"],
            "PDB",
            "ihm_feature_list", ["RID", "structure_id", "feature_id"],
            constraint_names=[[
                "PDB",
                "ihm_derived_dihedral_restraint_ihm_feature_list_3_combo1_fkey"
            ]],
            on_update="CASCADE",
            on_delete="NO ACTION"),
        ForeignKey.define(
            ["Feature_Id_4_RID", "structure_id", "feature_id_4"],
            "PDB",
            "ihm_feature_list", ["RID", "structure_id", "feature_id"],
            constraint_names=[[
                "PDB",
                "ihm_derived_dihedral_restraint_ihm_feature_list_4_combo1_fkey"
            ]],
            on_update="CASCADE",
            on_delete="NO ACTION"),
        ForeignKey.define(
            ["Dataset_List_RID", "structure_id", "dataset_list_id"],
            "PDB",
            "ihm_dataset_list", ["RID", "structure_id", "id"],
            constraint_names=[[
                "PDB",
                "ihm_derived_dihedral_restraint_ihm_dataset_list_combo1_fkey"
            ]],
            on_update="CASCADE",
            on_delete="NO ACTION"),
        ForeignKey.define(
            ["group_conditionality"],
            "Vocab",
            "ihm_derived_dihedral_restraint_group_conditionality", ["Name"],
            constraint_names=[[
                "Vocab",
                "ihm_derived_dihedral_restraint_group_conditionality_fkey"
            ]],
            on_update="CASCADE",
            on_delete="NO ACTION"),
        ForeignKey.define(
            ["restraint_type"],
            "Vocab",
            "ihm_derived_dihedral_restraint_restraint_type", ["Name"],
            constraint_names=[[
                "Vocab", "ihm_derived_dihedral_restraint_restraint_type_fkey"
            ]],
            on_update="CASCADE",
            on_delete="NO ACTION"),
        ForeignKey.define(
            ["Entry_Related_File"],
            "PDB",
            "Entry_Related_File", ["RID"],
            constraint_names=[[
                "PDB", "ihm_derived_dihedral_restraint_Entry_Related_File_fkey"
            ]],
            on_update="CASCADE",
            on_delete="NO ACTION")
    ]

    table_def = Table.define(table_name,
                             column_defs,
                             key_defs=key_defs,
                             fkey_defs=fkey_defs,
                             comment=comment,
                             provide_system=True)

    return table_def