Skip to content

Commit

Permalink
Merge pull request #63 from 3dem/label-seq-id
Browse files Browse the repository at this point in the history
Fix for issue #51
  • Loading branch information
jamaliki authored Aug 22, 2023
2 parents 72197d6 + 185edf6 commit 6f9cc1b
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions model_angelo/utils/save_pdb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import pickle
from typing import List, Union
from copy import deepcopy

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -69,6 +70,17 @@ def points_to_xyz(path_to_save, points, zyx_order=False):
f.write(f"C {point[2]} {point[1]} {point[0]}\n")


def save_structure_to_cif(structure, path_to_save: str):
io = MMCIFIO()
io.set_structure(structure)
# These are switched, as pointed out by Tristan Croll
auth_seq_id = deepcopy(io.dic["_atom_site.label_seq_id"])
label_seq_id = deepcopy(io.dic["_atom_site.auth_seq_id"])
io.dic["_atom_site.label_seq_id"] = label_seq_id
io.dic["_atom_site.auth_seq_id"] = auth_seq_id
io.save(path_to_save)


def points_to_pdb(path_to_save, points):
struct = StructureBuilder()
struct.init_structure("1")
Expand All @@ -80,9 +92,7 @@ def points_to_pdb(path_to_save, points):
struct.init_residue(f"ALA", " ", i, " ")
struct.init_atom("CA", point, 0, 1, " ", "CA", "C")
struct = struct.get_structure()
io = MMCIFIO()
io.set_structure(struct)
io.save(path_to_save)
save_structure_to_cif(struct, path_to_save)


def ca_ps_to_pdb(path_to_save, ca_points, p_points):
Expand Down Expand Up @@ -118,9 +128,7 @@ def ca_ps_to_pdb(path_to_save, ca_points, p_points):
element="P",
)
struct = struct.get_structure()
io = MMCIFIO()
io.set_structure(struct)
io.save(path_to_save)
save_structure_to_cif(struct, path_to_save)


def chains_to_pdb(path_to_save, chains):
Expand All @@ -135,9 +143,7 @@ def chains_to_pdb(path_to_save, chains):
struct.init_residue(f"ALA", " ", j, " ")
struct.init_atom("CA", point, 0, 1, " ", "CA", "C")
struct = struct.get_structure()
io = MMCIFIO()
io.set_structure(struct)
io.save(path_to_save)
save_structure_to_cif(struct, path_to_save)


def to_xyz(directory):
Expand Down Expand Up @@ -208,9 +214,7 @@ def atom14_to_cif(
)
res_counter += 1
struct = struct.get_structure()
io = MMCIFIO()
io.set_structure(struct)
io.save(path_to_save)
save_structure_to_cif(struct, path_to_save)


def protein_to_cif(
Expand Down Expand Up @@ -280,9 +284,7 @@ def protein_to_cif(
)
res_counter += 1
struct = struct.get_structure()
io = MMCIFIO()
io.set_structure(struct)
io.save(path_to_save)
save_structure_to_cif(struct, path_to_save)


def chain_atom14_to_cif(
Expand Down Expand Up @@ -363,9 +365,7 @@ def chain_atom14_to_cif(
res_counter += 1

struct = struct.get_structure()
io = MMCIFIO()
io.set_structure(struct)
io.save(path_to_save)
save_structure_to_cif(struct, path_to_save)


def write_chain_report(
Expand Down

0 comments on commit 6f9cc1b

Please sign in to comment.