1 |
stehr |
259 |
package proteinstructure; |
2 |
|
|
|
3 |
|
|
/** |
4 |
|
|
* A particular secondary structure element within a protein structure |
5 |
|
|
*/ |
6 |
|
|
public class SecStrucElement { |
7 |
|
|
|
8 |
stehr |
274 |
/*------------------------------ constants ------------------------------*/ |
9 |
filippis |
382 |
public enum ReducedState { THREESTATE, FOURSTATE, EIGHTSTATE }; |
10 |
stehr |
274 |
// three/four state secondary structure types (for 3 state, skip turn) |
11 |
|
|
public static final char HELIX = 'H'; // a helix |
12 |
|
|
public static final char STRAND = 'S'; // a beta strand |
13 |
|
|
public static final char TURN = 'T'; // a hydrogen bonded turn |
14 |
|
|
public static final char OTHER = 'O'; // all other states |
15 |
filippis |
382 |
public static final char EXTENTED = 'E';// all extented |
16 |
|
|
public static final char LOOP = 'L'; // all other states |
17 |
stehr |
274 |
|
18 |
stehr |
259 |
/*--------------------------- member variables --------------------------*/ |
19 |
|
|
|
20 |
stehr |
274 |
String secStrucId; // legacy field for old ss ids (e.g. H1, S1, ...) |
21 |
|
|
char secStrucType; // one of the above constants |
22 |
|
|
Interval interval; // the location of this element in the sequence |
23 |
stehr |
259 |
|
24 |
|
|
/*----------------------------- constructors ----------------------------*/ |
25 |
|
|
|
26 |
stehr |
274 |
public SecStrucElement(char secStrucType, int startRes, int endRes, String legacyId) { |
27 |
|
|
this.secStrucId = legacyId; |
28 |
|
|
this.secStrucType = secStrucType; |
29 |
stehr |
259 |
this.interval = new Interval(startRes, endRes); |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
/*---------------------------- public methods ---------------------------*/ |
33 |
|
|
|
34 |
stehr |
274 |
public SecStrucElement copy() { |
35 |
|
|
return new SecStrucElement(secStrucType, interval.beg, interval.end, secStrucId); |
36 |
stehr |
259 |
} |
37 |
|
|
|
38 |
stehr |
274 |
/** Returns the legacy ID of this element (e.g. H1, S1, ...) */ |
39 |
|
|
public String getId() { |
40 |
|
|
return secStrucId; |
41 |
stehr |
259 |
} |
42 |
|
|
|
43 |
stehr |
274 |
/** Returns the dssp type of this element. Valid values are H, S, T, O */ |
44 |
|
|
public char getType() { |
45 |
|
|
return secStrucType; |
46 |
|
|
} |
47 |
|
|
|
48 |
stehr |
259 |
/** Returns the range of this ss element in the sequence. */ |
49 |
|
|
public Interval getInterval() { |
50 |
|
|
return interval; |
51 |
|
|
} |
52 |
|
|
|
53 |
stehr |
274 |
/** Returns true if this ss element is a helix */ |
54 |
|
|
public boolean isHelix() { |
55 |
|
|
return secStrucType == HELIX; |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
/** Returns true if this ss element is a beta strand */ |
59 |
|
|
public boolean isStrand() { |
60 |
filippis |
382 |
return (secStrucType == STRAND || secStrucType == EXTENTED); |
61 |
stehr |
274 |
} |
62 |
|
|
|
63 |
|
|
/** Returns true if this ss element is a hydrogen bonded turn */ |
64 |
|
|
public boolean isTurn() { |
65 |
|
|
return secStrucType == TURN; |
66 |
|
|
} |
67 |
|
|
|
68 |
|
|
/*---------------------------- static methods ---------------------------*/ |
69 |
|
|
|
70 |
filippis |
382 |
private static char getFourStateTypeFromDsspType(char dsspType) { |
71 |
stehr |
259 |
char type = dsspType; |
72 |
|
|
switch(dsspType) { |
73 |
|
|
case 'H': |
74 |
|
|
case 'G': |
75 |
|
|
case 'I': |
76 |
stehr |
274 |
type = HELIX; |
77 |
stehr |
259 |
break; |
78 |
|
|
case 'E': |
79 |
stehr |
274 |
type = STRAND; |
80 |
stehr |
259 |
break; |
81 |
|
|
case 'T': |
82 |
stehr |
274 |
type = TURN; |
83 |
stehr |
259 |
break; |
84 |
|
|
case 'S': |
85 |
stehr |
274 |
case 'B': |
86 |
|
|
type = OTHER; |
87 |
stehr |
259 |
break; |
88 |
stehr |
274 |
default: |
89 |
|
|
type = OTHER; |
90 |
stehr |
259 |
} |
91 |
|
|
return type; |
92 |
|
|
} |
93 |
stehr |
274 |
|
94 |
filippis |
382 |
private static char getThreeStateTypeFromDsspType(char dsspType) { |
95 |
|
|
char type = dsspType; |
96 |
|
|
switch(dsspType) { |
97 |
|
|
case 'H': |
98 |
|
|
case 'G': |
99 |
|
|
case 'I': |
100 |
|
|
type = HELIX; |
101 |
|
|
break; |
102 |
|
|
case 'E': |
103 |
|
|
case 'B': |
104 |
|
|
type = EXTENTED; |
105 |
|
|
break; |
106 |
|
|
case 'T': |
107 |
|
|
case 'S': |
108 |
|
|
type = LOOP; |
109 |
|
|
break; |
110 |
|
|
default: |
111 |
|
|
type = LOOP; |
112 |
|
|
} |
113 |
|
|
return type; |
114 |
|
|
} |
115 |
|
|
|
116 |
|
|
public static char getReducedStateTypeFromDsspType(char dsspType, ReducedState state) { |
117 |
|
|
switch(state) { |
118 |
|
|
case THREESTATE: |
119 |
|
|
return getThreeStateTypeFromDsspType(dsspType); |
120 |
|
|
case FOURSTATE: |
121 |
|
|
return getFourStateTypeFromDsspType(dsspType); |
122 |
|
|
case EIGHTSTATE: |
123 |
|
|
default: |
124 |
|
|
return dsspType; |
125 |
|
|
} |
126 |
|
|
} |
127 |
|
|
|
128 |
stehr |
259 |
} |