-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdescriptors.py
930 lines (810 loc) · 38.1 KB
/
descriptors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
# -*- coding: utf-8 -*-
"""
##############################################################################
A class used for computing different types of protein descriptors.
It contains descriptors from packages pydpi, biopython, pfeature and modlamp.
Authors: Ana Marta Sequeira
Date: 05/2019 ALTERED 01/2020
Email:
##############################################################################
"""
from features_functions.aa_index import get_aa_index1, get_aa_index23
from features_functions.binary import bin_aa_ct
from features_functions.binary_aa_properties import bin_pc_wp
from features_functions.descriptors_modlamp import GlobalDescriptor, PeptideDescriptor
from features_functions.bondcomp import boc_wp
from features_functions.aa_composition import calculate_aa_composition, \
calculate_dipeptide_composition, get_spectrum_dict
from features_functions.pseudo_aac import get_pseudo_aac, get_a_pseudo_aac
from features_functions.autocorrelation import \
calculate_normalized_moreau_broto_auto_total, calculate_moran_auto_total, calculate_geary_auto_total
from features_functions.ctd import calculate_ctd
from features_functions.quasi_sequence_order import \
get_sequence_order_coupling_number_total, get_quasi_sequence_order
from features_functions.quasi_sequence_order import \
get_sequence_order_coupling_numberp, get_quasi_sequence_orderp
from features_functions.conjoint_triad import calculate_conjoint_triad
from Bio.SeqUtils.ProtParam import ProteinAnalysis
class Descriptor:
"""
The Descriptor class collects all descriptor calculation functions into a simple class.
Some of the descriptors functions are based on code from pydpi (altered to python3), modlamp, pfature and biopython.
It returns the features in a dictionary object
"""
AALetter = ["A", "R", "N", "D", "C", "E", "Q", "G", "H", "I", "L", "K", "M", "F", "P", "S", "T", "W", "Y", "V"]
Version = 1.0
def __init__(self, protein_sequence): # the function takes as input the protein sequence
""" constructor """
self.ProteinSequence = protein_sequence
# ################# GET AA INDEX (from specific property) ##################
def get_aa_index1(self, name, path='.'):
"""
Get the amino acid property values from aaindex1
(function from pydpi)
:param name: name is the name of amino acid property (e.g., KRIW790103)
:param path: path to get aa index. by default is the one in the package.
:return: result is a dict form containing the properties of 20 amino acids
"""
return get_aa_index1(name, path=path)
def get_aa_index23(self, name, path='.'):
"""
Get the amino acid property values from aaindex2 and aaindex3
(function from from pydpi)
:param name: name is the name of amino acid property (e.g.,TANS760101,GRAR740104)
:param path: path to get aa index. by default is the one in the package.
:return: result is a dict form containing the properties of 400 amino acid pairs
"""
return get_aa_index23(name, path=path)
# ################# BINARY PROFILES DESCRIPTORS ##################
def get_bin_aa(self, alphabet="ARNDCEQGHILKMFPSTWYV"):
"""
binary profile of aminoacid composition
alphabet: alphabet to use. by default 20 aa alphabet "ARNDCEQGHILKMFPSTWYV",
if using an alphabet with X, the X will be eliminated,if using an alphabet with all possible characters,
the strange aminoacids will be substituted by similar aa.
alphabet_x = "ARNDCEQGHILKMFPSTWYVX"
alphabet_all_characters = "ARNDCEQGHILKMFPSTWYVXBZUO"
:return: dictionary containing binary profile
"""
res = {}
result = bin_aa_ct(self.ProteinSequence, alphabet)
columns = []
count = 1
aa = 1
for x in range(len(self.ProteinSequence)):
for y in range(len(alphabet)):
name_feature = '{}_{}'.format(count, aa)
count += 1
aa += 1
if aa == len(alphabet) + 1:
aa = 1
columns.append(name_feature)
res[name_feature] = result[x][y]
# for i in range(len(self.ProteinSequence)):
# for residue in range(len(result) - 1):
# for value in range(20):
# name_feature = 'bin_aa' + '_' + str(residue) + '_' + str(value)
# res[name_feature] = result[residue].split(",")[value]
return res
def get_bin_resi_prop(self,
list_descriptors=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24)):
"""
Binary profile of residues for 25 phychem feature
:param list_descriptors: ist containing feature numbers (valid number, 0-24) (e.g. [5,4,8,24]
FEATURE NAME FEATURE NUMBER
'Positively charged' -- 0
'Negatively charged' -- 1
'Neutral charged' -- 2
'Polarity' -- 3
'Non polarity' -- 4
'Aliphaticity' -- 5
'Cyclic' -- 6
'Aromaticity' -- 7
'Acidicity'-- 8
'Basicity'-- 9
'Neutral (ph)' -- 10
'Hydrophobicity' -- 11
'Hydrophilicity' -- 12
'Neutral' -- 13
'Hydroxylic' -- 14
'Sulphur content' - 15
'Secondary Structure(Helix)' 16
'Secondary Structure(Strands)', 17
'Secondary Structure(Coil)', 18
'Solvent Accessibilty (Buried)', 19
'Solvent Accesibilty(Exposed)', 20
'Solvent Accesibilty(Intermediate)', 21
'Tiny', 22
'Small', 23
'Large' 24
:return: dict form with binary values
"""
res = bin_pc_wp(self.ProteinSequence, list_descriptors)
return res
# ################# PHYSICO CHEMICAL DESCRIPTORS ##################
def get_lenght(self):
"""
Calculates lenght of sequence (number of aa)
:return: dictionary with the value of lenght
"""
res = {}
res['lenght'] = float(len(self.ProteinSequence.strip()))
return res
def get_charge(self, ph=7.4, amide=False):
"""
Calculates charge of sequence (1 value) from modlamp
:param ph: ph considered to calculate. 7.4 by default
:param amide: by default is not considered an amide protein sequence.
:return: dictionary with the value of charge
"""
res = {}
desc = GlobalDescriptor(self.ProteinSequence)
desc.calculate_charge(ph=ph, amide=amide)
res['charge'] = desc.descriptor[0][0]
return res
def get_charge_density(self, ph=7.0, amide=False):
"""
Calculates charge density of sequence (1 value) from modlamp
:param ph: ph considered to calculate. 7 by default
:param amide: by default is not considered an amide protein sequence.
:return: dictionary with the value of charge density
"""
res = {}
desc = GlobalDescriptor(self.ProteinSequence)
desc.charge_density(ph, amide)
res['chargedensity'] = desc.descriptor[0][0]
return res
def get_formula(self, amide=False):
"""
Calculates number of C,H,N,O and S of the aa of sequence (5 values) from modlamp
:param amide: by default is not considered an amide protein sequence.
:return: dictionary with the 5 values of C,H,N,O and S
"""
res = {}
desc = GlobalDescriptor(self.ProteinSequence)
desc.formula(amide)
formula = desc.descriptor[0][0].split()
for atom in formula:
if atom[0] == 'C': res['formulaC'] = int(atom[1:])
if atom[0] == 'H': res['formulaH'] = int(atom[1:])
if atom[0] == 'N': res['formulaN'] = int(atom[1:])
if atom[0] == 'O': res['formulaO'] = int(atom[1:])
if atom[0] == 'S': res['formulaS'] = int(atom[1:])
# some formulas, specially S sometimes culd be a zero, to not transform iinto a nan in dataset
if not res.get('formulaC'): res['formulaC'] = 0
if not res.get('formulaH'): res['formulaH'] = 0
if not res.get('formulaN'): res['formulaN'] = 0
if not res.get('formulaO'): res['formulaO'] = 0
if not res.get('formulaS'): res['formulaS'] = 0
return res
def get_bond(self):
"""
This function gives the sum of the bond composition for each type of bond
For bond composition four types of bonds are considered
total number of bonds (including aromatic), hydrogen bond, single bond and double bond.
:return: dictionary with 4 values
"""
res = boc_wp(self.ProteinSequence)
return res
def get_mw(self):
"""
Calculates molecular weight of sequence (1 value) from modlamp
:return: dictionary with the value of molecular weight
"""
res = {}
desc = GlobalDescriptor(self.ProteinSequence)
desc.calculate_MW(amide=True)
res['MW_modlamp'] = desc.descriptor[0][0]
return res
# def GetMW2(self): give values different molecular weight from modlamp and biopython.
# """
# Calculates molecular weight from sequence (1 value) from biopython
# Input:
# Output: dictionary with the value of MW
# """
#
# res={}
# analysed_seq = ProteinAnalysis(self.protein_sequence)
# res['MW']= analysed_seq.molecular_weight()
# return res
def get_gravy(self):
"""
Calculates Gravy from sequence (1 value) from biopython
:return: dictionary with the value of gravy
"""
res = {}
analysed_seq = ProteinAnalysis(self.ProteinSequence)
res['Gravy'] = analysed_seq.gravy()
return res
def get_aromacity(self):
"""
Calculates Aromacity from sequence (1 value) from biopython
:return: dictionary with the value of aromacity
"""
res = {}
analysed_seq = ProteinAnalysis(self.ProteinSequence)
res['Aromacity'] = analysed_seq.aromaticity()
return res
def get_isoelectric_point(self):
"""
Calculates Isolectric Point from sequence (1 value) from biopython
:return: dictionary with the value of Isolectric Point
"""
res = {}
analysed_seq = ProteinAnalysis(self.ProteinSequence)
res['IsoelectricPoint'] = analysed_seq.isoelectric_point()
return res
# def GetIsoelectricPoint_2(self):#give values different molecular weight from modlamp and biopython
# """
# Calculates Isolectric Point from sequence (1 value) from modlamp
# Input:
# Output: dictionary with the value of Isolectric Point
# """
#
# res={}
# desc = GlobalDescriptor(self.protein_sequence)
# desc.isoelectric_point()
# res['isoelectricpoint_modlamp']= desc.descriptor[0][0]
# return res
def get_instability_index(self):
"""
Calculates Instability index from sequence (1 value) from biopython
:return: dictionary with the value of Instability index
"""
res = {}
analysed_seq = ProteinAnalysis(self.ProteinSequence)
res['Instability_index'] = analysed_seq.instability_index()
return res
def get_sec_struct(self):
"""
Calculates the fraction of amino acids which tend to be in helix, turn or sheet (3 value) from biopython
:return: dictionary with the 3 value of helix, turn, sheet
"""
res = {}
analysed_seq = ProteinAnalysis(self.ProteinSequence)
res['SecStruct_helix'] = analysed_seq.secondary_structure_fraction()[0] # helix
res['SecStruct_turn'] = analysed_seq.secondary_structure_fraction()[1] # turn
res['SecStruct_sheet'] = analysed_seq.secondary_structure_fraction()[2] # sheet
return res
def get_molar_extinction_coefficient(
self): # [reduced, oxidized] # with reduced cysteines / # with disulfid bridges
"""
Calculates the molar extinction coefficient (2 values) from biopython
:return: dictionary with the value of reduced cysteins and oxidized (with disulfid bridges)
"""
res = {}
analysed_seq = ProteinAnalysis(self.ProteinSequence)
res['Molar_extinction_coefficient_reduced'] = analysed_seq.molar_extinction_coefficient()[0] # reduced
res['Molar_extinction_coefficient_oxidized'] = analysed_seq.molar_extinction_coefficient()[1] # cys cys bounds
return res
def get_flexibility(self):
"""
Calculates the flexibility according to Vihinen, 1994 (return proteinsequencelenght-9 values ) from biopython
:return: dictionary with proteinsequencelenght-9 values of flexiblity
"""
res = {}
analysed_seq = ProteinAnalysis(self.ProteinSequence)
flexibility = analysed_seq.flexibility()
for i in range(len(flexibility)):
res['flexibility_' + str(i)] = flexibility[i]
return res
def get_aliphatic_index(self):
"""
Calculates aliphatic index of sequence (1 value) from modlamp
:return: dictionary with the value of aliphatic index
"""
res = {}
desc = GlobalDescriptor(self.ProteinSequence)
desc.aliphatic_index()
res['aliphatic_index'] = desc.descriptor[0][0]
return res
def get_boman_index(self):
"""
Calculates boman index of sequence (1 value) from modlamp
:return: dictionary with the value of boman index
"""
res = {}
desc = GlobalDescriptor(self.ProteinSequence)
desc.boman_index()
res['bomanindex'] = desc.descriptor[0][0]
return res
def get_hydrophobic_ratio(self):
"""
Calculates hydrophobic ratio of sequence (1 value) from modlamp
:return: dictionary with the value of hydrophobic ratio
"""
res = {}
desc = GlobalDescriptor(self.ProteinSequence)
desc.hydrophobic_ratio()
res['hydrophobic_ratio'] = desc.descriptor[0][0]
return res
################## AMINO ACID COMPOSITION ##################
def get_aa_comp(self):
"""
Calculates amino acid compositon (20 values) from pydpi
:return: dictionary with the fractions of all 20 aa(keys are the aa)
"""
res = calculate_aa_composition(self.ProteinSequence)
return res
def get_dp_comp(self):
"""
Calculates dipeptide composition (400 values) from pydpi
:return: dictionary with the fractions of all 400 possible combiinations of 2 aa
"""
res = calculate_dipeptide_composition(self.ProteinSequence)
return res
def get_tp_comp(self):
"""
Calculates tripeptide composition (8000 values) from pydpi
:return: dictionary with the fractions of all 8000 possible combinations of 3 aa
"""
res = get_spectrum_dict(self.ProteinSequence)
return res
################## PSEUDO AMINO ACID COMPOSITION ##################
def get_paac(self, lamda=10, weight=0.05):
"""
Calculates Type I Pseudo amino acid composition (default is 30, depends on lamda) from pydpi
:param lamda: reflects the rank of correlation and is a non-Negative integer, such as 10.
should NOT be larger than the length of input protein sequence
when lamda =0, the output of PseAA server is the 20-D amino acid composition
:param weight: weight on the additional PseAA components. with respect to the conventional AA components.
The user can select any value within the region from 0.05 to 0.7 for the weight factor.
:return: dictionary with the fractions of all PAAC (keys are the PAAC). Number of keys depends on lamda
"""
res = get_pseudo_aac(self.ProteinSequence, lamda=lamda, weight=weight)
return res
def get_paac_p(self, lamda=10, weight=0.05, AAP=[]):
"""
Calculates Type I Pseudo amino acid composition for a given property (default is 30, depends on lamda) from pydpi
:param lamda: reflects the rank of correlation and is a non-Negative integer, such as 10.
should NOT be larger than the length of input protein sequence
when lamda =0, theoutput of PseAA server is the 20-D amino acid composition
:param weight: weight on the additional PseAA components. with respect to the conventional AA components.
The user can select any value within the region from 0.05 to 0.7 for the weight factor.
:param AAP: list of properties. each of which is a dict form.
PseudoAAC._Hydrophobicity,PseudoAAC._hydrophilicity, PseudoAAC._residuemass,PseudoAAC._pK1,PseudoAAC._pK2,PseudoAAC._pI
:return: dictionary with the fractions of all PAAC(keys are the PAAC). Number of keys depends on lamda
"""
res = get_pseudo_aac(self.ProteinSequence, lamda=lamda, weight=weight, AAP=AAP)
return res
def get_apaac(self, lamda=10, weight=0.5):
"""
Calculates Type II Pseudo amino acid composition - Amphiphilic (default is 30, depends on lamda) from pydpi
:param lamda: reflects the rank of correlation and is a non-Negative integer, such as 10.
should NOT be larger than the length of input protein sequence
when lamda =0, theoutput of PseAA server is the 20-D amino acid composition
:param weight: weight on the additional PseAA components. with respect to the conventional AA components.
The user can select any value within the region from 0.05 to 0.7 for the weight factor.
:return: dictionary with the fractions of all PAAC(keys are the PAAC). Number of keys depends on lamda
"""
res = get_a_pseudo_aac(self.ProteinSequence, lamda=lamda, weight=weight)
return res
# ################# AUTOCORRELATION DESCRIPTORS ##################
def get_moreau_broto_auto(self):
"""
Calculates Normalized Moreau-Broto autocorrelation (240 values) from pydpi
:return: dictionary with the 240 descriptors
"""
res = calculate_normalized_moreau_broto_auto_total(self.ProteinSequence)
return res
def get_moran_auto(self):
"""
Calculates Moran autocorrelation (240 values) from pydpi
:return: dictionary with the 240 descriptors
"""
res = calculate_moran_auto_total(self.ProteinSequence)
return res
def get_geary_auto(self):
"""
Calculates Geary autocorrelation (240 values) from pydpi
:return: dictionary with the 240 descriptors
"""
res = calculate_geary_auto_total(self.ProteinSequence)
return res
# ################# COMPOSITION, TRANSITION, DISTRIBUTION ##################
def get_ctd(self):
"""
Calculates the Composition Transition Distribution descriptors (147 values) from pydpi
:return: dictionary with the 147 descriptors
"""
res = calculate_ctd(self.ProteinSequence)
return res
# ################# CONJOINT TRIAD ##################
def get_conj_t(self):
"""
Calculates the Conjoint Triad descriptors (343 descriptors) from pydpi
:return: dictionary with the 343 descriptors
"""
res = calculate_conjoint_triad(self.ProteinSequence)
return res
# ################# SEQUENCE ORDER ##################
def get_socn(self, maxlag=45):
"""
Calculates the Sequence order coupling numbers (retrieves 90 values by default) from pydpi
:param maxlag: maximum lag. Smaller than length of the protein
:return: dictionary with the descriptors (90 descriptors)
"""
res = get_sequence_order_coupling_number_total(self.ProteinSequence, maxlag=maxlag)
return res
def get_socn_p(self, maxlag=45, distancematrix={}):
"""
Calculates the Sequence order coupling numbers (retrieves 90 values by default) from pydpi
:param maxlag: maximum lag. Smaller than length of the protein
:param distancematrix: dict form containing 400 distance values
:return: dictionary with the descriptors (90 descriptors)
"""
res = get_sequence_order_coupling_numberp(self.ProteinSequence, maxlag=maxlag, distancematrix=distancematrix)
return res
def get_qso(self, maxlag=30, weight=0.1):
"""
Calculates the Quasi sequence order (retrieves 100 values by default) from pydpi
:param maxlag: maximum lag. Smaller than length of the protein
:param weight:
:return: dictionary with the descriptors (100 descriptors)
"""
res = get_quasi_sequence_order(self.ProteinSequence, maxlag=maxlag, weight=weight)
return res
def get_qso_p(self, maxlag=30, weight=0.1, distancematrix={}):
"""
Calculates the Quasi sequence order (retrieves 100 values by default) from pydpi
:param maxlag: maximum lag. Smaller than length of the protein
:param weight:
:param distancematrix: dict form containing 400 distance values
:return: dictionary with the descriptors (100 descriptors)
"""
res = get_quasi_sequence_orderp(self.ProteinSequence, maxlag=maxlag, weight=weight,
distancematrix=distancematrix)
return res
# ################# BASE CLASS PEPTIDE DESCRIPTOR ##################
"""amino acid descriptor scales available are the ones from modlamo.
For more information please check: https://modlamp.org/modlamp.html#modlamp.descriptors.PeptideDescriptor
amino acid sclaes include AASI, argos, bulkiness, charge_phys, charge_acid, eisenberg and others."""
def calculate_moment(self, window=1000, angle=100, modality='max', scalename='Eisenberg'):
"""
Calculates moment of sequence (1 value) from modlamp
:param window: amino acid window in which to calculate the moment. If the sequence is shorter than the window, the length of the sequence is taken
:param angle: angle in which to calculate the moment. 100 for alpha helices, 180 for beta sheets
:param modality: maximum or mean hydrophobic moment
:param scalename:
:return: dictionary with one value of moment
"""
res = {}
AMP = PeptideDescriptor(self.ProteinSequence, scalename)
AMP.calculate_moment(window, angle, modality)
res['moment'] = AMP.descriptor[0][0]
return res
def calculate_global(self, window=1000, modality='max', scalename='Eisenberg'):
"""
Calculates a global / window averaging descriptor value of a given AA scale of sequence (1 value) from modlamp
:param window: amino acid window. If the sequence is shorter than the window, the length of the sequence is taken
:param modality: maximum or mean hydrophobic moment
:param scalename:
:return: dictionary with one value
"""
res = {}
AMP = PeptideDescriptor(self.ProteinSequence, scalename)
AMP.calculate_global(window, modality)
res['global'] = AMP.descriptor[0][0]
return res
def calculate_profile(self, prof_type='uH', window=7, scalename='Eisenberg'):
"""
Calculates hydrophobicity or hydrophobic moment profiles for given sequences and fitting for slope and intercep
(2 values) from modlamp
:param prof_type: prof_type of profile, ‘H’ for hydrophobicity or ‘uH’ for hydrophobic moment
:param window: size of sliding window used (odd-numbered)
:param scalename:
:return: dictionary with two value
"""
res = {}
AMP = PeptideDescriptor(self.ProteinSequence, scalename)
AMP.calculate_profile(prof_type, window)
desc = AMP.descriptor[0]
for i in range(len(desc)):
res['profile_' + str(i)] = desc[i]
return res
def calculate_arc(self, modality="max", scalename='peparc'):
"""
Calculates arcs as seen in the helical wheel plot. Use for binary amino acid scales only ( 5 values) from modlamp
:param modality: maximum or mean
:param scalename: binary amino acid scales only
:return: dictionary with 5 values
"""
res = {}
arc = PeptideDescriptor(self.ProteinSequence, scalename)
arc.calculate_arc(modality)
desc = arc.descriptor[0]
for i in range(len(desc)):
res['arc_' + str(i)] = desc[i]
return res
def calculate_autocorr(self, window, scalename='Eisenberg'):
"""
Calculates autocorrelation of amino acid values for a given descriptor scale ( variable >>>>>>values) from modlamp
:param window: correlation window for descriptor calculation in a sliding window approach
:param scalename:
:return: dictionary with values of autocorrelation
"""
res = {}
AMP = PeptideDescriptor(self.ProteinSequence, scalename)
AMP.calculate_autocorr(window)
desc = AMP.descriptor[0]
for i in range(len(desc)):
res['autocorr_' + str(i)] = desc[i]
return res
def calculate_crosscorr(self, window, scalename='Eisenberg'):
"""
Calculates cross correlation of amino acid values for a given descriptor scale ( variable >>>>>>values) from modlamp
:param window:correlation window for descriptor calculation in a sliding window approach
:param scalename:
:return: dictionary with values of crosscorrelation
"""
res = {}
AMP = PeptideDescriptor(self.ProteinSequence, scalename)
AMP.calculate_crosscorr(window)
desc = AMP.descriptor[0]
for i in range(len(desc)):
res['crosscorr_' + str(i)] = desc[i]
return res
# ################# GET ALL FUNCTIONS ##################
def get_all_physicochemical(self, ph=7, amide=False):
"""
Calculate all 15 geral descriptors functions derived from biopython and modlpam
:param ph: for functions Charge, charge density and formula
:param amide: for functions Charge, charge density and formula
:return: dictionary with variable number of descriptors
"""
res = {}
res.update(self.get_lenght())
res.update(self.get_charge(ph, amide))
res.update(self.get_charge_density(ph, amide))
res.update(self.get_formula(amide))
res.update(self.get_bond())
res.update(self.get_mw())
# res.update(self.GetMW2())
res.update(self.get_gravy())
res.update(self.get_aromacity())
res.update(self.get_isoelectric_point())
# res.update(self.GetIsoelectricPoint2())
res.update(self.get_instability_index())
res.update(self.get_sec_struct())
res.update(self.get_molar_extinction_coefficient())
# res.update(self.get_flexibility())
res.update(self.get_aliphatic_index())
res.update(self.get_boman_index())
res.update(self.get_hydrophobic_ratio())
return res
def get_all_aac(self):
"""
Calculate all descriptors from Amino Acid Composition
:return: dictionary with values from AAC, DPC and TPC
"""
res = {}
res.update(self.get_aa_comp())
res.update(self.get_dp_comp())
res.update(self.get_tp_comp())
return res
def get_all_paac(self, lamda_paac=10, weight_paac=0.05, lamda_apaac=10, weight_apaac=0.05):
"""
Calculate all descriptors from Pseudo Amino Acid Composition
:param lamda_paac: parameter for PAAC default 10
:param weight_paac: parameter for PAAC default 0.05
:param lamda_apaac: parameter for APAAC default 10
:param weight_apaac: parameter for APAAC default 0.05
:return: dictionary with values from PAAC and APAAC
"""
res = {}
lamda = lamda_paac
weight = weight_paac
res.update(self.get_paac(lamda, weight))
lamda = lamda_apaac
weight = weight_apaac
res.update(self.get_apaac(lamda, weight))
return res
def get_all_sequenceorder(self, maxlag_socn=45, maxlag_qso=30, weight_qso=0.1):
"""
Calculate all values for sequence order descriptors
:param maxlag_socn: parameter for SOCN default 45
:param maxlag_qso: parameter for QSO default 30
:param weight_qso: parameter for QSO default 0.1
:return: dictionary with values for quasi sequence order and sequence order couplig numbers
"""
res = {}
maxlag = maxlag_socn
res.update(self.get_socn(maxlag))
maxlag = maxlag_qso
weight = weight_qso
res.update(self.get_qso(maxlag, weight))
return res
def get_all_correlation(self):
"""
Calculate all descriptors from Autocorrelation
:return: values for the funtions Moreau Broto, Moran and Geary autocorrelation
"""
res = {}
res.update(self.get_moreau_broto_auto())
res.update(self.get_moran_auto())
res.update(self.get_geary_auto())
return res
def get_all_base_class(self, window=7, scalename='Eisenberg', scalename_arc='peparc', angle=100, modality='max',
prof_type='uH'):
"""
Calculate all functions from Base class
:param window:
:param scalename:
:param scalename_arc:
:param angle:
:param modality:
:param prof_type:
:return: dictionary with all 6 base class peptide descriptors (the value is variable)
"""
res = {}
res.update(self.calculate_autocorr(window, scalename))
res.update(self.calculate_crosscorr(window, scalename))
res.update(self.calculate_moment(window, angle, modality, scalename))
res.update(self.calculate_global(window, modality, scalename))
res.update(self.calculate_profile(prof_type, window, scalename))
res.update(self.calculate_arc(modality, scalename_arc))
return res
def get_all(self, ph=7, amide=False, tricomp=False, bin_aa=False, bin_prop=False, lamda_paac=10, weight_paac=0.05,
lamda_apaac=10, weight_apaac=0.05, maxlag_socn=45, maxlag_qso=30, weight_qso=0.1, window=7,
scalename='Eisenberg', scalename_arc='peparc', angle=100, modality='max', prof_type='uH'):
"""
Calculate all descriptors from pydpi_py3 except tri-peptide pydpi_py3 and binary profiles
:param ph:parameters for geral descriptors
:param amide:parameters for geral descriptors
:param tricomp: true or false to calculate or not tri-peptide pydpi_py3
:param bin_aa: true or false to calculate or not binary composition of aa
:param bin_prop: true or false to calculate or not binary composition of properties of resides
:param lamda_paac: parameters for PAAC: lamdaPAAC=10 should not be larger than len(sequence)
:param weight_paac: parameters for PAAC weightPAAC=0.05
:param AAP: list with
:param lamda_apaac: parmeters for APAAC lamdaAPAAC=10
:param weight_apaac:parmeters for APAAC weightAPAAC=0.05
:param maxlag_socn: parameters for SOCN: maxlagSOCN=45
:param maxlag_qso:parameters for QSO maxlagQSO=30
:param weight_qso:parameters for weightQSO=0.1
:param window:parameters for base class descriptors
:param scalename:parameters for base class descriptors
:param scalename_arc:parameters for base class descriptors
:param angle:parameters for base class descriptors
:param modality:parameters for base class descriptors
:param prof_type:parameters for base class descriptors
:return:dictionary with all features (value is variable)
"""
res = {}
if bin_aa == True: res.update(self.get_bin_aa())
if bin_prop == True: res.update(self.get_bin_resi_prop())
# Geral
res.update(self.get_lenght())
res.update(self.get_charge(ph, amide))
res.update(self.get_charge_density(ph, amide))
res.update(self.get_formula(amide))
res.update(self.get_bond())
res.update(self.get_mw())
# res.update(self.GetMW2())
res.update(self.get_gravy())
res.update(self.get_aromacity())
res.update(self.get_isoelectric_point())
# res.update(self.GetIsoelectricPoint2())
res.update(self.get_instability_index())
res.update(self.get_sec_struct())
res.update(self.get_molar_extinction_coefficient())
# res.update(self.get_flexibility()) (ver se é o q esta causar nas)
res.update(self.get_aliphatic_index())
res.update(self.get_boman_index())
res.update(self.get_hydrophobic_ratio())
# pydpi_based
res.update(self.get_aa_comp())
res.update(self.get_dp_comp())
if tricomp == True: res.update(self.get_tp_comp())
res.update(self.get_moreau_broto_auto())
res.update(self.get_moran_auto())
res.update(self.get_geary_auto())
res.update(self.get_ctd())
res.update(self.get_conj_t())
lamda = lamda_paac
weight = weight_paac
res.update(self.get_paac(lamda, weight))
lamda = lamda_apaac
weight = weight_apaac
res.update(self.get_apaac(lamda, weight))
maxlag = maxlag_socn
res.update(self.get_socn(maxlag))
maxlag = maxlag_qso
weight = weight_qso
res.update(self.get_qso(maxlag, weight))
# base class
res.update(self.calculate_autocorr(window, scalename))
res.update(self.calculate_crosscorr(window, scalename))
res.update(self.calculate_moment(window, angle, modality, scalename))
res.update(self.calculate_global(window, modality, scalename))
res.update(self.calculate_profile(prof_type, window, scalename))
res.update(self.calculate_arc(modality, scalename_arc))
return res
def adaptable(self, list_of_functions=[], ph=7, amide=False, tricomp=False, lamda_paac=10, weight_paac=0.05,
lamda_apaac=10, weight_apaac=0.05, aap=[], maxlag_socn=45, maxlag_qso=30, weight_qso=0.1,
distancematrix={}, window=7, scalename='Eisenberg', scalename_arc='peparc', angle=100,
modality='max', prof_type='uH'):
"""
Function to calculate user selected descriptors
:param ph:parameters for geral descriptors
:param amide:parameters for geral descriptors
:param tricomp: true or false to calculate or not tri-peptide on get_all
:param lamda_paac: parameters for PAAC: lamdaPAAC=10
:param weight_paac: parameters for PAAC weightPAAC=0.05
:param lamda_apaac: parmeters for APAAC lamdaAPAAC=5 IT SHOULD NOT BE LARGER THAN LENGHT SEQUENCE
:param weight_apaac:parmeters for APAAC weightAPAAC=0.05
:param aap:
:param maxlag_socn: parameters for SOCN: maxlagSOCN=45
:param maxlag_qso:parameters for QSO maxlagQSO=30
:param weight_qso:parameters for weightQSO=0.1
:param distancematrix:
:param window:parameters for base class descriptors
:param scalename:parameters for base class descriptors
:param scalename_arc:parameters for base class descriptors
:param angle:parameters for base class descriptors
:param modality:parameters for base class descriptors
:param prof_type:parameters for base class descriptors
:return:dictionary with all features (value is variable)
:param list_of_functions:
"""
res = {}
for function in list_of_functions:
if function == 1: res.update(self.get_bin_aa())
if function == 2: res.update(self.get_bin_resi_prop())
if function == 3: res.update(self.get_lenght())
if function == 4: res.update(self.get_charge(ph, amide))
if function == 5: res.update(self.get_charge_density(ph, amide))
if function == 6: res.update(self.get_formula(amide))
if function == 7: res.update(self.get_bond())
if function == 8: res.update(self.get_mw())
if function == 9: res.update(self.get_gravy())
if function == 10: res.update(self.get_aromacity())
if function == 11: res.update(self.get_isoelectric_point())
if function == 12: res.update(self.get_instability_index())
if function == 13: res.update(self.get_sec_struct())
if function == 14: res.update(self.get_molar_extinction_coefficient())
if function == 16: res.update(self.get_flexibility())
if function == 16: res.update(self.get_aliphatic_index())
if function == 17: res.update(self.get_boman_index())
if function == 18: res.update(self.get_hydrophobic_ratio())
if function == 19: res.update(self.get_all_physicochemical(ph, amide))
if function == 20: res.update(self.get_aa_comp())
if function == 21: res.update(self.get_dp_comp())
if function == 22: res.update(self.get_tp_comp())
if function == 23: res.update(self.get_all_aac())
lamda = lamda_paac
weight = weight_paac
if function == 24: res.update(self.get_paac(lamda, weight))
if function == 25: res.update(self.get_paac_p(lamda, weight, aap))
lamda = lamda_apaac
weight = weight_apaac
if function == 26: res.update(self.get_apaac(lamda, weight))
if function == 27: res.update(self.get_all_paac(lamda_paac, weight_paac, lamda_apaac, weight_apaac))
if function == 28: res.update(self.get_moreau_broto_auto())
if function == 29: res.update(self.get_moran_auto())
if function == 30: res.update(self.get_geary_auto())
if function == 31: res.update(self.get_all_correlation())
if function == 32: res.update(self.get_ctd())
if function == 33: res.update(self.get_conj_t())
maxlag = maxlag_socn
if function == 34: res.update(self.get_socn(maxlag))
if function == 35: res.update(self.get_socn_p(maxlag, distancematrix))
maxlag = maxlag_qso
weight = weight_qso
if function == 36: res.update(self.get_qso(maxlag, weight))
if function == 36: res.update(self.get_qso_p(maxlag, weight, distancematrix))
if function == 37: res.update(self.get_all_sequenceorder(maxlag_socn, maxlag_qso, weight_qso))
# base class
if function == 38: res.update(self.calculate_autocorr(window, scalename))
if function == 39: res.update(self.calculate_crosscorr(window, scalename))
if function == 40: res.update(self.calculate_moment(window, angle, modality, scalename))
if function == 41: res.update(self.calculate_global(window, modality, scalename))
if function == 42: res.update(self.calculate_profile(prof_type, window, scalename))
if function == 43: res.update(self.calculate_arc(modality, scalename_arc))
if function == 44: res.update(self.get_all_base_class(window, scalename, scalename_arc))
if function == 45: res.update(
self.get_all(ph, amide, tricomp, lamda_paac, weight_paac, lamda_apaac, weight_apaac, maxlag_socn,
maxlag_qso,
weight_qso, window, scalename, scalename_arc, angle, modality, prof_type))
return res