1 |
package proteinstructure; |
2 |
|
3 |
/** |
4 |
* A particular secondary structure element within a protein structure |
5 |
*/ |
6 |
public class SecStrucElement { |
7 |
|
8 |
/*------------------------------ constants ------------------------------*/ |
9 |
// three/four state secondary structure types (for 3 state, skip turn) |
10 |
public static final char HELIX = 'H'; // a helix |
11 |
public static final char STRAND = 'S'; // a beta strand |
12 |
public static final char TURN = 'T'; // a hydrogen bonded turn |
13 |
public static final char OTHER = 'O'; // all other states |
14 |
|
15 |
/*--------------------------- member variables --------------------------*/ |
16 |
|
17 |
String secStrucId; // legacy field for old ss ids (e.g. H1, S1, ...) |
18 |
char secStrucType; // one of the above constants |
19 |
Interval interval; // the location of this element in the sequence |
20 |
|
21 |
/*----------------------------- constructors ----------------------------*/ |
22 |
|
23 |
public SecStrucElement(char secStrucType, int startRes, int endRes, String legacyId) { |
24 |
this.secStrucId = legacyId; |
25 |
this.secStrucType = secStrucType; |
26 |
this.interval = new Interval(startRes, endRes); |
27 |
} |
28 |
|
29 |
/*---------------------------- public methods ---------------------------*/ |
30 |
|
31 |
public SecStrucElement copy() { |
32 |
return new SecStrucElement(secStrucType, interval.beg, interval.end, secStrucId); |
33 |
} |
34 |
|
35 |
/** Returns the legacy ID of this element (e.g. H1, S1, ...) */ |
36 |
public String getId() { |
37 |
return secStrucId; |
38 |
} |
39 |
|
40 |
/** Returns the dssp type of this element. Valid values are H, S, T, O */ |
41 |
public char getType() { |
42 |
return secStrucType; |
43 |
} |
44 |
|
45 |
/** Returns the range of this ss element in the sequence. */ |
46 |
public Interval getInterval() { |
47 |
return interval; |
48 |
} |
49 |
|
50 |
/** Returns true if this ss element is a helix */ |
51 |
public boolean isHelix() { |
52 |
return secStrucType == HELIX; |
53 |
} |
54 |
|
55 |
/** Returns true if this ss element is a beta strand */ |
56 |
public boolean isStrand() { |
57 |
return secStrucType == STRAND; |
58 |
} |
59 |
|
60 |
/** Returns true if this ss element is a hydrogen bonded turn */ |
61 |
public boolean isTurn() { |
62 |
return secStrucType == TURN; |
63 |
} |
64 |
|
65 |
/*---------------------------- static methods ---------------------------*/ |
66 |
|
67 |
public static char getFourStateTypeFromDsspType(char dsspType) { |
68 |
char type = dsspType; |
69 |
switch(dsspType) { |
70 |
case 'H': |
71 |
case 'G': |
72 |
case 'I': |
73 |
type = HELIX; |
74 |
break; |
75 |
case 'E': |
76 |
type = STRAND; |
77 |
break; |
78 |
case 'T': |
79 |
type = TURN; |
80 |
break; |
81 |
case 'S': |
82 |
case 'B': |
83 |
type = OTHER; |
84 |
break; |
85 |
default: |
86 |
type = OTHER; |
87 |
} |
88 |
return type; |
89 |
} |
90 |
|
91 |
} |