pdb_to_fasta.py

Extracts amino acid (or nucleotide) sequence from a PDB file
USAGE:
python pdb_to_fasta.py 2gb1.pdb

Categories:

  • core/data/io/find_pdb

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


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

    Extracts amino acid (or nucleotide) sequence from a PDB file
USAGE:
    python pdb_to_fasta.py 2gb1.pdb

    CATEGORIES: core/data/io/find_pdb
    KEYWORDS:   PDB input; FASTA; Format convertion

  """)
  sys.exit()

for pdb_fname in sys.argv[1:] :
  structure = find_pdb(pdb_fname, "./").create_structure(0)
  for ic in range(structure.count_chains()) :
    chain = structure[ic]
    print(">",structure.code(), chain.id())
    print(chain.create_sequence().sequence)
../_images/file_icon.png