-
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.
fix index count & add subset_pdb_to_fasta,_gui.py and executable
- Loading branch information
1 parent
5cd3908
commit 7bf1618
Showing
4 changed files
with
108 additions
and
20 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
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# python3 | ||
import os | ||
from gooey import * | ||
from Bio.PDB import * | ||
from Bio import SeqIO | ||
from Bio.Seq import Seq | ||
from Bio.SeqRecord import SeqRecord | ||
# input parameters | ||
@Gooey(required_cols=2, program_name='subset pdb to fasta', header_bg_color= '#DCDCDC', terminal_font_color= '#DCDCDC', terminal_panel_color= '#DCDCDC') | ||
def main(): | ||
ap = GooeyParser() | ||
ap.add_argument("-pdb", "--pdb", required=True, widget='FileChooser', help="input pdb file") | ||
ap.add_argument("-model", "--model",required=False, default=0, 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("-start", "--start", required=False, default=1, type=int, help="amino acid in chain to start writing the fasta file") | ||
ap.add_argument("-end", "--end", required=False, type=int, help="amino acid in chain to end writing the fasta file") | ||
ap.add_argument("-pro", "--program", required=False,default=1, type=int, help="program to choose 1) add both start and end location 2) the end location with be that of the latest amino acid in the chain. Default is 1") | ||
args = vars(ap.parse_args()) | ||
# main | ||
# select chain | ||
parser = PDBParser() | ||
s = parser.get_structure("name", args['pdb']) | ||
fill = s[int(args['model'])][args['chain']] | ||
# retrieve the pdb id of the input file | ||
filename = os.path.split(args['pdb'])[1] | ||
pdb_id = filename.split(".")[0] | ||
# retrieve chain amino acids | ||
ppb = PPBuilder() | ||
for pp in ppb.build_peptides(fill): | ||
aa_chain = str(pp.get_sequence()) | ||
# choose program | ||
if args['program'] == 1: | ||
# fix the index for start parameter | ||
if args['start'] > 0: | ||
aa_start = args['start'] -1 | ||
else: | ||
print("-start parameter must be a positive integer") | ||
exit(1) | ||
# fix the index for end parameter | ||
if args['end'] > 0: | ||
aa_end = args['end'] -1 | ||
else: | ||
aa_end = args['end'] | ||
else: | ||
|
||
# fix the index for start parameter | ||
if args['start'] > 0: | ||
aa_start = args['start'] -1 | ||
else: | ||
print("-start parameter must be a positive integer") | ||
exit(1) | ||
# fix the index for end parameter | ||
args['end'] = len(aa_chain) -1 | ||
aa_end = args['end'] | ||
# subset based on aa in chain | ||
sub_seq = aa_chain[aa_start:aa_end] | ||
# export to fasta | ||
record = SeqRecord(Seq(sub_seq),id="".join([str(pdb_id),"_",str(args['chain']),"_",str(args['start']),"_",str(args['end'])]),description="") | ||
SeqIO.write(record, "".join([str(pdb_id),"_",str(args['chain']),"_",str(args['start']),"_",str(args['end']),".fasta"]), "fasta") | ||
|
||
if __name__ == '__main__': | ||
main() |