-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextract_pairs.py
executable file
·32 lines (28 loc) · 1.05 KB
/
extract_pairs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
import sys
import Bio.PDB as bpdb
import numpy as np
import itertools
from scipy.spatial import cKDTree
pdb_path = sys.argv[1]
outname = pdb_path.replace(".pdb","")
pdbparser = bpdb.PDBParser(PERMISSIVE=1,QUIET = True)
pdb_file = pdbparser.get_structure('',pdb_path)[0]
print('# of atom : ', len(list(pdb_file.get_atoms())))
print('# of chains : ',len(list(pdb_file.get_chains())))
print(list(pdb_file.get_chains()))
chain_ids = list(pdb_file.get_chains())
#structure = bpdb.StructureBuilder.Model(0) # create empty structure
#io = bpdb.PDBIO()
for chain_a in pdb_file.get_chains():
for chain_b in pdb_file.get_chains():
if chain_a.get_id() == chain_b.get_id():
continue
print(chain_a.get_id(),chain_b.get_id())
structure = bpdb.StructureBuilder.Model(0) # create empty structure
io = bpdb.PDBIO()
structure.add(chain_a)
structure.add(chain_b)
io.set_structure(structure)
io.save(outname + "_extracted_pair_" + chain_a.get_id() + "_"+ chain_b.get_id() + ".pdb")
break