ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/trunk/proteinstructure/SecStrucElement.java
Revision: 505
Committed: Thu Jan 10 13:37:09 2008 UTC (16 years, 9 months ago) by duarte
File size: 3910 byte(s)
Log Message:
Now converting also secondary structure in pairwise alignment graph conversion
Line User Rev File contents
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 duarte 455 // four state secondary structure types
11 stehr 274 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 duarte 455
16     // three state secondary structure types, add also HELIX from above
17 filippis 382 public static final char EXTENTED = 'E';// all extented
18     public static final char LOOP = 'L'; // all other states
19 stehr 274
20 stehr 259 /*--------------------------- member variables --------------------------*/
21    
22 stehr 274 String secStrucId; // legacy field for old ss ids (e.g. H1, S1, ...)
23     char secStrucType; // one of the above constants
24     Interval interval; // the location of this element in the sequence
25 stehr 259
26     /*----------------------------- constructors ----------------------------*/
27    
28 duarte 505 public SecStrucElement(char secStrucType, int startRes, int endRes, String secStrucId) {
29     this.secStrucId = secStrucId;
30 stehr 274 this.secStrucType = secStrucType;
31 stehr 259 this.interval = new Interval(startRes, endRes);
32     }
33    
34     /*---------------------------- public methods ---------------------------*/
35    
36 stehr 274 public SecStrucElement copy() {
37     return new SecStrucElement(secStrucType, interval.beg, interval.end, secStrucId);
38 stehr 259 }
39    
40 stehr 274 /** Returns the legacy ID of this element (e.g. H1, S1, ...) */
41     public String getId() {
42     return secStrucId;
43 stehr 259 }
44    
45 stehr 274 /** Returns the dssp type of this element. Valid values are H, S, T, O */
46     public char getType() {
47     return secStrucType;
48     }
49    
50 stehr 259 /** Returns the range of this ss element in the sequence. */
51     public Interval getInterval() {
52     return interval;
53     }
54    
55 filippis 407 public char getSheetSerial() {
56 filippis 383 if (isStrand()) {
57     return Character.isLetter(secStrucId.charAt(1))?secStrucId.charAt(1):0;
58     }
59     return 0;
60     }
61    
62 stehr 274 /** Returns true if this ss element is a helix */
63     public boolean isHelix() {
64     return secStrucType == HELIX;
65     }
66    
67     /** Returns true if this ss element is a beta strand */
68     public boolean isStrand() {
69 filippis 382 return (secStrucType == STRAND || secStrucType == EXTENTED);
70 stehr 274 }
71    
72     /** Returns true if this ss element is a hydrogen bonded turn */
73     public boolean isTurn() {
74     return secStrucType == TURN;
75     }
76 filippis 383
77     /** Returns true if this ss element is other ... */
78     public boolean isOther() {
79     return (secStrucType == OTHER || secStrucType == LOOP);
80     }
81 stehr 274
82 filippis 383 public boolean inSameSheet(SecStrucElement s) {
83     boolean inSameSheet = false;
84     if (s != null && this.isStrand() && s.isStrand() && (s.getSheetSerial() == this.getSheetSerial() && s.getSheetSerial() != 0)) {
85     inSameSheet = true;
86     }
87     return inSameSheet;
88     }
89    
90 stehr 274 /*---------------------------- static methods ---------------------------*/
91    
92 filippis 382 private static char getFourStateTypeFromDsspType(char dsspType) {
93 stehr 259 char type = dsspType;
94     switch(dsspType) {
95     case 'H':
96     case 'G':
97     case 'I':
98 stehr 274 type = HELIX;
99 stehr 259 break;
100     case 'E':
101 stehr 274 type = STRAND;
102 stehr 259 break;
103     case 'T':
104 stehr 274 type = TURN;
105 stehr 259 break;
106     case 'S':
107 stehr 274 case 'B':
108     type = OTHER;
109 stehr 259 break;
110 stehr 274 default:
111     type = OTHER;
112 stehr 259 }
113     return type;
114     }
115 stehr 274
116 filippis 382 private static char getThreeStateTypeFromDsspType(char dsspType) {
117     char type = dsspType;
118     switch(dsspType) {
119     case 'H':
120     case 'G':
121     case 'I':
122     type = HELIX;
123     break;
124     case 'E':
125     case 'B':
126     type = EXTENTED;
127     break;
128     case 'T':
129     case 'S':
130     type = LOOP;
131     break;
132     default:
133     type = LOOP;
134     }
135     return type;
136     }
137    
138     public static char getReducedStateTypeFromDsspType(char dsspType, ReducedState state) {
139     switch(state) {
140     case THREESTATE:
141     return getThreeStateTypeFromDsspType(dsspType);
142     case FOURSTATE:
143     return getFourStateTypeFromDsspType(dsspType);
144     case EIGHTSTATE:
145     default:
146     return dsspType;
147     }
148     }
149    
150 stehr 259 }