pdb_to_ss2.py

Extracts amino acid (or nucleotide) sequence from a PDB file
USAGE:
python3 pdb_to_ss2.py input.pdb [putput.ss2]
EXAMPLE:
python3 pdb_to_ss2.py 2gb1.pdb 2gb1.out python3 pdb_to_ss2.py 2kwi.pdb

Categories:

  • core/data/io/write_ss2

Program source:

 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
import sys
sys.path.append('../../../../../bin/')
from pybioshell.core.data.io import find_pdb, write_ss2


if len(sys.argv) < 2 :
  print("""

    Extracts amino acid (or nucleotide) sequence from a PDB file
USAGE:
    python3 pdb_to_ss2.py input.pdb [putput.ss2]

EXAMPLE:
    python3 pdb_to_ss2.py 2gb1.pdb 2gb1.out
    python3 pdb_to_ss2.py 2kwi.pdb

    CATEGORIES: core/data/io/write_ss2
    KEYWORDS:   PDB input; secondary structure; Format convertion
  """)
  sys.exit()

structure = find_pdb(sys.argv[1], "./").create_structure(0)
outname = sys.argv[2] if len(sys.argv) > 2 else "stdout"
for ic in range(structure.count_chains()) :
    chain = structure[ic]
    ss = chain.create_sequence()
    write_ss2(ss,outname)
    print() # Print empty line to separate chain: note that it works only when printed to stdout
    
../_images/file_icon.png