コード例 #1
0
def main(path):
    print "parsing %s" % (path)

    cif_file = mmCIFFile()
    cif_file.load_file(path)

    os.mkdir("Monomers")

    for cif_data in cif_file:

        mkdir_path = os.path.join("Monomers", cif_data.name[0])
        if not os.path.isdir(mkdir_path):
            os.mkdir(mkdir_path)

        save_path = os.path.join(mkdir_path, "%s.cif" % (cif_data.name))

        print "saving %s" % (save_path)

        cf = mmCIFFile()
        cf.append(copy.deepcopy(cif_data))
        cf.save_file(save_path)
コード例 #2
0
ファイル: cif2html.py プロジェクト: Sree-Inventrust/pymmlib
def cif2html(cif_path, html_path):
    fileobj = FileIO.OpenFile(cif_path, "r")

    cif_file = mmCIF.mmCIFFile()
    print "loading..."
    cif_file.load_file(fileobj)
    print "converting..."
    cif_data = cif_file[0]

    c2h_template = kid.Template(file="cif2html.kid")
    c2h_template.cif = mmCIFDataKid(cif_data)
    c2h_template.write(html_path)
コード例 #3
0
ファイル: make_library.py プロジェクト: masci/mmLib
def main(path):
    print "parsing %s" % (path)

    cif_file = mmCIFFile()
    cif_file.load_file(path)

    os.mkdir("Monomers")

    for cif_data in cif_file:

        mkdir_path = os.path.join("Monomers", cif_data.name[0])
        if not os.path.isdir(mkdir_path):
            os.mkdir(mkdir_path)

        save_path = os.path.join(mkdir_path, "%s.cif" % (cif_data.name))

        print "saving %s" % (save_path)

        cf = mmCIFFile()
        cf.append(copy.deepcopy(cif_data))
        cf.save_file(save_path)
コード例 #4
0
ファイル: cif2html.py プロジェクト: masci/mmLib
def cif2html(cif_path, html_path):
    fileobj = FileIO.OpenFile(cif_path, "r")

    cif_file = mmCIF.mmCIFFile()
    print "loading..."
    cif_file.load_file(fileobj)
    print "converting..."
    cif_data = cif_file[0]

    c2h_template = kid.Template(file = "cif2html.kid")
    c2h_template.cif = mmCIFDataKid(cif_data)
    c2h_template.write(html_path)
コード例 #5
0
ファイル: rcsbdep.py プロジェクト: masci/mmLib
def cif_merge(merge_paths, output_path, entry_id):
    """Merge the mmCIF files in merge_paths into a mmCIF file which will be 
    written to the output_path. This merging is configured for a 
    crystallographic structure, and the entry_ids of all tables are
    overridden with the given entry_id.
    """
    output_cif_file = mmCIF.mmCIFFile()
    output_cif_data = output_cif_file.new_data(entry_id)

    ## add the entry table to the output mmCIFFile
    entry = output_cif_data.new_table("entry", ["id"])
    row = entry.new_row()
    row["id"] = entry_id

    ## merge in mmCIF files
    for mpath in merge_paths:
        merge_cif_file = mmCIF.mmCIFFile()
        merge_cif_file.load_file(mpath)

        for src_data in merge_cif_file:
            for src_table in src_data:

                ## don't merge the entry table
                if src_table.name == "entry":
                    continue

                vet_merge_cif_table_entry_id(src_table, entry_id)
                default_table_merge(output_cif_data, src_table)

    ## post-process merged mmCIF file

    ## make sure the entry_id fields are filled in
    for cif_table in output_cif_data:
        add_entry_id(cif_table, entry_id)

    ## report missing items
    rcsb_report_missing(output_cif_data)

    output_cif_file.save_file(output_path)
コード例 #6
0
def cif_merge(merge_paths, output_path, entry_id):
    """Merge the mmCIF files in merge_paths into a mmCIF file which will be 
    written to the output_path. This merging is configured for a 
    crystallographic structure, and the entry_ids of all tables are
    overridden with the given entry_id.
    """
    output_cif_file = mmCIF.mmCIFFile()
    output_cif_data = output_cif_file.new_data(entry_id)

    ## add the entry table to the output mmCIFFile
    entry = output_cif_data.new_table("entry", ["id"])
    row = entry.new_row()
    row["id"] = entry_id

    ## merge in mmCIF files
    for mpath in merge_paths:
        merge_cif_file = mmCIF.mmCIFFile()
        merge_cif_file.load_file(mpath)

        for src_data in merge_cif_file:
            for src_table in src_data:

                ## don't merge the entry table
                if src_table.name == "entry":
                    continue

                vet_merge_cif_table_entry_id(src_table, entry_id)
                default_table_merge(output_cif_data, src_table)

    ## post-process merged mmCIF file

    ## make sure the entry_id fields are filled in
    for cif_table in output_cif_data:
        add_entry_id(cif_table, entry_id)

    ## report missing items
    rcsb_report_missing(output_cif_data)

    output_cif_file.save_file(output_path)