-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wrap lines in fasta file, added link to gui executable
- Loading branch information
1 parent
5224525
commit 5cd3908
Showing
2 changed files
with
18 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |