1 |
duarte |
179 |
package proteinstructure; |
2 |
|
|
|
3 |
|
|
import java.util.TreeMap; |
4 |
|
|
import java.util.Collections; |
5 |
|
|
|
6 |
|
|
public class EdgeNbh extends TreeMap<Integer,String> { |
7 |
|
|
|
8 |
|
|
|
9 |
|
|
private static final long serialVersionUID = 1L; |
10 |
|
|
|
11 |
|
|
// central edge residues |
12 |
|
|
public int i_resser; |
13 |
|
|
public String i_resType; |
14 |
|
|
public int j_resser; |
15 |
|
|
public String j_resType; |
16 |
|
|
|
17 |
|
|
public EdgeNbh(int i_resser, String i_resType, int j_resser, String j_resType){ |
18 |
|
|
super(); |
19 |
|
|
this.i_resser=i_resser; |
20 |
|
|
this.i_resType=i_resType; |
21 |
|
|
this.j_resser=j_resser; |
22 |
|
|
this.j_resType=j_resType; |
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
public String getMotif(){ |
26 |
|
|
String motif=""; |
27 |
|
|
int min=Math.min(Math.min(i_resser,j_resser), Collections.min(this.keySet())); |
28 |
|
|
int max=Math.max(Math.max(i_resser,j_resser), Collections.max(this.keySet())); |
29 |
duarte |
196 |
int gapSize=0; |
30 |
|
|
String gap=""; |
31 |
duarte |
179 |
for (int i=min;i<=max;i++){ |
32 |
|
|
if (this.containsKey(i)){ |
33 |
duarte |
196 |
motif+=gap; |
34 |
|
|
motif+=AA.threeletter2oneletter(this.get(i)); |
35 |
|
|
gapSize=0; |
36 |
|
|
gap=""; |
37 |
|
|
} else if (i==i_resser){ |
38 |
|
|
motif+=gap; |
39 |
|
|
motif+="x"; |
40 |
|
|
gapSize=0; |
41 |
|
|
gap=""; |
42 |
|
|
} else if (i==j_resser){ |
43 |
|
|
motif+=gap; |
44 |
|
|
motif+="y"; |
45 |
|
|
gapSize=0; |
46 |
|
|
gap=""; |
47 |
|
|
} else { |
48 |
|
|
gapSize++; |
49 |
|
|
gap="_{"+gapSize+"}"; |
50 |
|
|
} |
51 |
|
|
} |
52 |
|
|
return motif; |
53 |
|
|
} |
54 |
|
|
|
55 |
|
|
public String getMotifFullGaps(){ |
56 |
|
|
String motif=""; |
57 |
|
|
int min=Math.min(Math.min(i_resser,j_resser), Collections.min(this.keySet())); |
58 |
|
|
int max=Math.max(Math.max(i_resser,j_resser), Collections.max(this.keySet())); |
59 |
|
|
for (int i=min;i<=max;i++){ |
60 |
|
|
if (this.containsKey(i)){ |
61 |
duarte |
179 |
motif+=AA.threeletter2oneletter(this.get(i)); |
62 |
|
|
} else if (i==i_resser){ |
63 |
|
|
motif+="x"; |
64 |
|
|
} else if (i==j_resser){ |
65 |
|
|
motif+="y"; |
66 |
|
|
} else { |
67 |
|
|
motif+="_"; |
68 |
|
|
} |
69 |
|
|
} |
70 |
|
|
return motif; |
71 |
|
|
} |
72 |
|
|
|
73 |
duarte |
196 |
public String toString(){ |
74 |
|
|
if (this.isEmpty()) return ""; |
75 |
|
|
else return this.getMotif(); |
76 |
|
|
} |
77 |
duarte |
179 |
} |