Mercurial > repos > jay > pdaug_merge_dataframes
comparison PDAUG_Peptide_Global_Descriptors/PDAUG_Peptide_Global_Descriptors.py @ 0:5bb52d4bf172 draft
"planemo upload for repository https://github.com/jaidevjoshi83/pdaug commit a9bd83f6a1afa6338cb6e4358b63ebff5bed155e"
author | jay |
---|---|
date | Wed, 28 Oct 2020 01:54:31 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:5bb52d4bf172 |
---|---|
1 from modlamp.descriptors import * | |
2 import os | |
3 import pandas as pd | |
4 | |
5 def Descriptor_calcultor(DesType, inputfile, ph, amide,OutFile ): | |
6 | |
7 list_pep_name = [] | |
8 f = open(inputfile) | |
9 lines = f.readlines() | |
10 | |
11 for line in lines: | |
12 if ">" in line: | |
13 pass | |
14 else: | |
15 list_pep_name.append(line.strip('\n')) | |
16 | |
17 desc = GlobalDescriptor(list_pep_name) | |
18 | |
19 if DesType == "Length": | |
20 desc.length() | |
21 df = desc.descriptor | |
22 dfN = desc.featurenames | |
23 | |
24 elif DesType == "Weight": | |
25 | |
26 desc.calculate_MW() | |
27 df = desc.descriptor | |
28 dfN = desc.featurenames | |
29 | |
30 elif DesType == "Charge": | |
31 desc.calculate_charge(ph=int(ph), amide=amide) | |
32 df = desc.descriptor | |
33 dfN = desc.featurenames | |
34 | |
35 elif DesType == "ChargeDensity": | |
36 desc.charge_density(ph=int(ph), amide=amide) | |
37 df = desc.descriptor | |
38 dfN = desc.featurenames | |
39 | |
40 elif DesType == "IsoelectricPoint": | |
41 desc.isoelectric_point(amide=amide) | |
42 df = desc.descriptor | |
43 dfN = desc.featurenames | |
44 | |
45 elif DesType == "InstabilityIndex": | |
46 desc.instability_index() | |
47 df = desc.descriptor | |
48 dfN = desc.featurenames | |
49 | |
50 elif DesType == "Aromaticity": | |
51 desc.aromaticity() | |
52 df = desc.descriptor | |
53 dfN = desc.featurenames | |
54 | |
55 elif DesType == "AliphaticIndex": | |
56 desc.aliphatic_index() | |
57 df = desc.descriptor | |
58 dfN = desc.featurenames | |
59 | |
60 elif DesType == "BomanIndex": | |
61 desc.boman_index() | |
62 df = desc.descriptor | |
63 dfN = desc.featurenames | |
64 | |
65 elif DesType == "HydrophobicRatio": | |
66 desc.hydrophobic_ratio() | |
67 df = desc.descriptor | |
68 dfN = desc.featurenames | |
69 | |
70 elif DesType == "All": | |
71 desc.calculate_all(ph=int(ph), amide=amide) | |
72 df = desc.descriptor | |
73 dfN = desc.featurenames | |
74 else: | |
75 pass | |
76 | |
77 df = desc.descriptor | |
78 dfN = desc.featurenames | |
79 dfOut = pd.DataFrame(df,columns=dfN) | |
80 | |
81 dfOut.to_csv(OutFile, index=False, sep='\t') | |
82 | |
83 if __name__=="__main__": | |
84 | |
85 import argparse | |
86 | |
87 parser = argparse.ArgumentParser() | |
88 | |
89 parser.add_argument("-t", "--DesType", | |
90 required=True, | |
91 default=None, | |
92 help="Descriptors Type") | |
93 | |
94 parser.add_argument("-i", "--InFile", | |
95 required=True, | |
96 default=None, | |
97 help="Peptide File") | |
98 | |
99 parser.add_argument("-p", "--Ph", | |
100 required=False, | |
101 default=7.0, | |
102 help="Ph 0-14") | |
103 | |
104 parser.add_argument("-a", "--Amide", | |
105 required=False, | |
106 default="True", | |
107 help="True or False") | |
108 | |
109 parser.add_argument("-O", "--OutFile", | |
110 required=False, | |
111 default="out.tsv", | |
112 help="True or False") | |
113 | |
114 | |
115 args = parser.parse_args() | |
116 | |
117 Descriptor_calcultor(args.DesType, args.InFile, args.Ph, args.Amide, args.OutFile) |