Mercurial > repos > jay > pdaug_tsvtofasta
diff PDAUG_Peptide_Structure_Builder/PDAUG_Peptide_Structure_Builder.py @ 0:c3f0b3a6339e draft
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit a9bd83f6a1afa6338cb6e4358b63ebff5bed155e"
author | jay |
---|---|
date | Wed, 28 Oct 2020 01:47:48 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PDAUG_Peptide_Structure_Builder/PDAUG_Peptide_Structure_Builder.py Wed Oct 28 01:47:48 2020 +0000 @@ -0,0 +1,73 @@ +import tempfile +import pandas as pd +import shutil +import sys +import glob +import fragbuilder +import openbabel +from fragbuilder import peptide + +import os + + +def read_pep_file(pep_infile): + + file = open(pep_infile) + lines = file.readlines() + + Index = [] + list_pep_name = [] + + for line in lines: + if '>' in line: + Index.append(line.strip('\n')) + else: + line = line.strip('\n') + line = line.strip('\r') + list_pep_name.append(line.strip('\n')) + + return list_pep_name + +def structure_gen(pep_seq, out_dir): + + if not os.path.exists(os.path.join(out_dir, 'DataFile')): + os.makedirs(os.path.join(out_dir, 'DataFile')) + + b = len(pep_seq) + + for seq in pep_seq: + + pep = peptide.Peptide(seq, nterm = "charged", cterm = "neutral") + pep.regularize() + pep.write_pdb(os.path.join(out_dir, 'DataFile', seq+".pdb")) + + obConversion = openbabel.OBConversion() + obConversion.SetInAndOutFormats("pdb", "sdf") + mol = openbabel.OBMol() + obConversion.ReadFile(mol, os.path.join(out_dir, 'DataFile', seq+".pdb")) + + mol.AddHydrogens() + + +def main_process(str_pep_file, out_dir): + + my_pep = read_pep_file(str_pep_file) + structure_gen(my_pep, out_dir) + + +if __name__=="__main__": + + + import argparse + parser = argparse.ArgumentParser() + + parser.add_argument("-p", "--pep", required=True, default=None, help="pep file") + parser.add_argument("-o", "--OutDir", required=None, default=os.getcwd(), help="Path to out file") + + args = parser.parse_args() + main_process(args.pep, args.OutDir) + + + + +