Mercurial > repos > jay > pdaug_tsvtofasta
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c3f0b3a6339e |
---|---|
1 import tempfile | |
2 import pandas as pd | |
3 import shutil | |
4 import sys | |
5 import glob | |
6 import fragbuilder | |
7 import openbabel | |
8 from fragbuilder import peptide | |
9 | |
10 import os | |
11 | |
12 | |
13 def read_pep_file(pep_infile): | |
14 | |
15 file = open(pep_infile) | |
16 lines = file.readlines() | |
17 | |
18 Index = [] | |
19 list_pep_name = [] | |
20 | |
21 for line in lines: | |
22 if '>' in line: | |
23 Index.append(line.strip('\n')) | |
24 else: | |
25 line = line.strip('\n') | |
26 line = line.strip('\r') | |
27 list_pep_name.append(line.strip('\n')) | |
28 | |
29 return list_pep_name | |
30 | |
31 def structure_gen(pep_seq, out_dir): | |
32 | |
33 if not os.path.exists(os.path.join(out_dir, 'DataFile')): | |
34 os.makedirs(os.path.join(out_dir, 'DataFile')) | |
35 | |
36 b = len(pep_seq) | |
37 | |
38 for seq in pep_seq: | |
39 | |
40 pep = peptide.Peptide(seq, nterm = "charged", cterm = "neutral") | |
41 pep.regularize() | |
42 pep.write_pdb(os.path.join(out_dir, 'DataFile', seq+".pdb")) | |
43 | |
44 obConversion = openbabel.OBConversion() | |
45 obConversion.SetInAndOutFormats("pdb", "sdf") | |
46 mol = openbabel.OBMol() | |
47 obConversion.ReadFile(mol, os.path.join(out_dir, 'DataFile', seq+".pdb")) | |
48 | |
49 mol.AddHydrogens() | |
50 | |
51 | |
52 def main_process(str_pep_file, out_dir): | |
53 | |
54 my_pep = read_pep_file(str_pep_file) | |
55 structure_gen(my_pep, out_dir) | |
56 | |
57 | |
58 if __name__=="__main__": | |
59 | |
60 | |
61 import argparse | |
62 parser = argparse.ArgumentParser() | |
63 | |
64 parser.add_argument("-p", "--pep", required=True, default=None, help="pep file") | |
65 parser.add_argument("-o", "--OutDir", required=None, default=os.getcwd(), help="Path to out file") | |
66 | |
67 args = parser.parse_args() | |
68 main_process(args.pep, args.OutDir) | |
69 | |
70 | |
71 | |
72 | |
73 |