7 def get_SSE_fragments(stride_file):
9 get all the SSE fragments info for the native structure from its
18 with open(stride_file,
'r') as infile:
20 if line.startswith(
'ASG '):
22 resid = int(line[10:15].strip())
25 if current_chain
is None or chain_id != current_chain:
26 current_chain = chain_id
27 stride_dict[current_chain] = {}
28 if sstype ==
'H' or sstype ==
'E':
29 stride_dict[current_chain][resid] = sstype
31 if sstype ==
'H' or sstype ==
'E':
32 stride_dict[current_chain][resid] = sstype
35 for chainid
in stride_dict:
39 for resid
in stride_dict[chainid]:
40 current_ss = stride_dict[chainid][resid]
41 if previous_ss
is None:
42 previous_ss = current_ss
46 if current_ss == previous_ss
and resid - previous_res < 2:
47 current_frag.append((resid, current_ss))
48 previous_ss = current_ss
51 current_frag.sort(key=
lambda y: y[0])
52 first_res = current_frag[0][0]
53 last_res = current_frag[-1][0]
54 length = len(current_frag)
55 new_key = (chainid +
'_' + current_frag[0][1] +
'_'
56 + str(first_res) +
'_' + str(last_res) +
'_'
58 frag_list.append(new_key)
59 current_frag = [(resid, current_ss)]
60 previous_ss = current_ss
63 if len(current_frag) > 1:
64 current_frag.sort(key=
lambda y: y[0])
65 first_res = current_frag[0][0]
66 last_res = current_frag[-1][0]
67 length = len(current_frag)
68 new_key = (chainid +
'_' + current_frag[0][1] +
'_'
69 + str(first_res) +
'_' + str(last_res) +
'_'
71 frag_list.append(new_key)
73 return frag_list, stride_dict
76 def get_fragment_coords(pdbname, frag_info, path_to_store_parts):
78 get coords from pdbname chain id and residue ranges
79 also save the pdbs of the helical fragments and check if for strands
80 there could be multiple strands possibilities
81 if 2 strands are possible then save 2-strand pdbs
86 outdir = path_to_store_parts
87 if not os.path.exists(outdir):
89 selected_atom_types = [
'N',
'CA',
'C',
'O',
'CB']
90 for frag
in frag_info:
92 chainid, SSEtype, firstres, lastres, length = frag.split(
'_')
97 native_h, chain_id=chainid,
98 residue_indexes=range(int(firstres), int(lastres)+1),
100 for n
in selected_atom_types])
101 pdb_name =
'_'.join([
'h', length, chainid,
102 firstres, lastres]) +
'.pdb'
104 all_pdbs.append(outdir +
'/' + pdb_name)
108 native_h, chain_id=chainid,
109 residue_indexes=range(int(firstres), int(lastres)+1),
111 for n
in selected_atom_types])
112 pdb_name =
'_'.join([
's', length, chainid,
113 firstres, lastres]) +
'.pdb'
115 all_pdbs.append(outdir +
'/' + pdb_name)
117 print(
'Something is wrong, should only process strands '
122 def per_chain_segment_coords(pdbname, segment_info, path_to_store_parts):
124 get coords from pdbname chain id and residue ranges
129 outdir = path_to_store_parts
130 if not os.path.exists(outdir):
132 selected_atom_types = [
'N',
'CA',
'C',
'O',
'CB']
133 for chains
in segment_info.keys():
134 all_residueids = list(segment_info[chains].keys())
135 print(all_residueids)
138 native_h, chain_id=chains,
139 residue_indexes=all_residueids,
141 pdb_name =
'_'.join([
'all', str(len(all_residueids)), chains,
142 str(all_residueids[0]),
143 str(all_residueids[-1])]) +
'.pdb'
145 all_pdbs.append(outdir +
'/' + pdb_name)
149 def mutate_frag_to_ala(pdbname):
151 mutate all residues from a pdb to ALA
153 import mutate_all_ALA
154 mutate_all_ALA.mutate_all_ALA(pdbname)
158 parser = argparse.ArgumentParser(
159 description=
'Generate a library of parts from native structure, '
160 'using the information from STRIDE')
161 parser.add_argument(
'ref_pdb', type=str,
162 help=
'Provide the absolute path of the native pdb '
163 '(we assumed that as reference PDB)')
164 parser.add_argument(
'ref_stride', type=str,
165 help=
'Provide the absolute path of the stride file')
166 parser.add_argument(
'path_to_store_parts', type=str,
167 help=
'path to store the generated parts')
169 parser.add_argument(
'--perChain', type=bool, default=
False,
170 help=
'get segments per chain')
171 args = parser.parse_args()
173 all_frags, stride_dict = get_SSE_fragments(args.ref_stride)
176 if not args.perChain:
177 all_new_pdbs = get_fragment_coords(args.ref_pdb, all_frags,
178 args.path_to_store_parts)
180 all_new_pdbs = per_chain_segment_coords(args.ref_pdb, stride_dict,
181 args.path_to_store_parts)
void write_pdb(const Selection &mhd, TextOutput out, unsigned int model=1)
void read_pdb(TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.
Select all non-alternative ATOM records.
Basic functionality that is expected to be used by a wide variety of IMP users.
Functionality for loading, creating, manipulating and scoring atomic structures.
Select hierarchy particles identified by the biological name.