Skip to content

Commit

Permalink
wrap lines in fasta file, added link to gui executable
Browse files Browse the repository at this point in the history
  • Loading branch information
olgatsiouri1996 committed Nov 17, 2021
1 parent 5224525 commit 5cd3908
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ python scripts that can be easily transformed to gui programs for wet lab scient
15. single-fastas to tabular GUI: [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5672075.svg)](https://doi.org/10.5281/zenodo.5672075)
16. tabular file to single-fastas GUI: [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5652249.svg)](https://doi.org/10.5281/zenodo.5652249)
17. fasta formatter GUI: [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5703665.svg)](https://doi.org/10.5281/zenodo.5703665)
18. chain pdb to fasta GUI: [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5706468.svg)](https://doi.org/10.5281/zenodo.5706468)
32 changes: 17 additions & 15 deletions pdb_corner/chain_pdb_to_fasta_gui.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
# python3
from gooey import *
from Bio.PDB import *
import sys
import os
from Bio import SeqIO
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
# input parameters
@Gooey(required_cols=5, program_name='pdb chain to fasta', header_bg_color= '#DCDCDC', terminal_font_color= '#DCDCDC', terminal_panel_color= '#DCDCDC')
@Gooey(required_cols=2, program_name='pdb chain to fasta', header_bg_color= '#DCDCDC', terminal_font_color= '#DCDCDC', terminal_panel_color= '#DCDCDC')
def main():
ap = GooeyParser(description="subsets a pdb file by selecting the model and chain and convert the output to fasta format")
ap.add_argument("-pdb", "--pdb", required=True, widget='FileChooser', help="input pdb file")
ap.add_argument("-model", "--model", required=True, help="model from pdb file to select(integer)")
ap.add_argument("-model", "--model",default=0, required=False, help="model from pdb file to select(integer). Default is 0(1 model only)")
ap.add_argument("-chain", "--chain", required=True, help="chain from pdb file to select")
ap.add_argument("-id", "--id", required=True, help="pdb id of the protein structure")
ap.add_argument("-fasta", "--fasta", required=True, widget='FileSaver', help="output fasta file")
args = vars(ap.parse_args())
#main
def seq_from_pdb(structure):
ppb = PPBuilder()
for pp in ppb.build_peptides(structure):
print(">"+args['id']+"_"+args['chain'],pp.get_sequence(), sep="\n")

# main
# select chain
parser = PDBParser()
s = parser.get_structure("name", args['pdb'])
fill = s[int(args['model'])][args['chain']]
sys.stdout = open(args['fasta'], 'a')
seq_from_pdb(fill)
sys.stdout.close()

# retrieve the pdb id of the input file
filename = os.path.split(args['pdb'])[1]
pdb_id = filename.split(".")[0]
# export to fasta
ppb = PPBuilder()
for pp in ppb.build_peptides(fill):
record = SeqRecord(Seq(str(pp.get_sequence())),id="".join([str(pdb_id),"_",str(args['chain'])]),description="")
SeqIO.write(record, "".join([str(pdb_id),"_",str(args['chain']),".fasta"]), "fasta")

if __name__ == '__main__':
main()

0 comments on commit 5cd3908

Please sign in to comment.