3 using System.Collections.Generic;
16 public List<int>
sslist =
new List<int> ();
23 private const int COIL = 2;
47 Vector3 r01 = at0 - at1;
48 Vector3 r32 = at3 - at2;
49 Vector3 r12 = at1 - at2;
51 Vector3 p = Vector3.Cross(r12, r01);
52 Vector3 q = Vector3.Cross(r12, r32);
53 Vector3 r = Vector3.Cross(r12, q);
55 float u = Vector3.Dot(q,q);
56 float v = Vector3.Dot(r,r);
59 if(u <= 0f || v <= 0f)
62 float u1 = Vector3.Dot(p,q);
63 float v1 = Vector3.Dot(p,r);
65 u = u1 / Mathf.Sqrt(u);
66 v = v1 / Mathf.Sqrt(v);
68 if(Mathf.Abs(u) > 0.01f || Mathf.Abs(v) > 0.01f)
69 a = Mathf.Rad2Deg * Mathf.Atan2(v,u);
74 Debug.Log(a.ToString());
79 Vector2 one =
new Vector2(x1, y1);
80 Vector2 two =
new Vector2(x2, y2);
81 return Vector2.Distance(one, two);
85 Debug.Log(
"Ribbons.cs::CalculateSecondaryStructures > Beginning.");
86 Vector3 c0, n1, ca1, c1, n2;
87 c0 = n1 = ca1 = c1 = n2 = Vector3.zero;
88 Dictionary<string, Vector3> res0, res1, res2;
89 int nbResDicts = residueDicts.Count;
91 float[] phi =
new float[nbResDicts];
92 float[] psi =
new float[nbResDicts];
94 for(
int i=0; i<nbResDicts; i++) {
95 if(i == 0 || i == nbResDicts-1) {
99 res0 = residueDicts[i-1];
100 res1 = residueDicts[i];
101 res2 = residueDicts[i+1];
105 success = success && res0.TryGetValue(
"C", out c0);
106 success = success && res1.TryGetValue(
"N", out n1);
107 success = success && res1.TryGetValue(
"CA", out ca1);
108 success = success && res1.TryGetValue(
"C", out c1);
109 success = success && res2.TryGetValue(
"N", out n2);
112 Debug.Log(
"Ribbons.cs::CalculateSecondaryStructures > Failed to get all the vectors.");
114 bool print = (i<100);
118 Debug.Log(i.ToString() +
": " + c0.ToString() +
" " + n1.ToString() +
" " + ca1.ToString() +
" " + c1.ToString() +
" " + n2.ToString());
132 float extension = 0f;
133 float strandExtension = 0f;
134 for(
int i=0; i<nbResDicts; i++) {
136 if((
WeirdDistance(phi[i], psi[i], -60f, -45f) < (30f + extension)) && (i < nbResDicts - 1)) {
141 if(3 <= nconsRHelix) {
142 for(
int k=firstHelix; k<i; k++) {
151 if((
WeirdDistance(phi[i], psi[i], 60f, 45f) < (30f + extension)) && (i < nbResDicts - 1)) {
156 if(3 <= nconsLHelix) {
157 for(
int k=firstHelix; k<i; k++) {
166 if((
WeirdDistance(phi[i], psi[i], -110f, 130f) < (30f + extension + strandExtension))
167 && (i< nbResDicts - 1)) {
172 if(2 <= nconsStrand) {
173 for(
int k=firstStrand; k<i; k++) {
186 private Vector3
LinearComb(
float scalar0, Vector3 vector0,
float scalar1, Vector3 vector1) {
187 return scalar0*vector0 + scalar1*vector1;
191 private void AddControlPoints(Vector3 ca0, Vector3 ox0, Vector3 ca1,
int ss,
int handedness) {
193 Vector3 A, B, C, D, p0, cpt0, cpt1, cpt2;
200 C = Vector3.Cross(A,B);
203 D = Vector3.Cross(C,A);
209 if( (ss != HELIX) && (90f < Vector3.Angle(flipTestV, D) ) )
221 cpt0 =
LinearComb(1f, p0, handedness*HELIX_DIAM, C);
226 cpt1 =
LinearComb(1f, cpt0, ribbonWidth[ss], D);
229 cpt2 =
LinearComb(1f, cpt0, - ribbonWidth[ss], D);
247 Vector3 ca0, ox0, ca1;
248 Vector3 p0, p1, p2, p3;
250 p1 = p2 = p3 = Vector3.zero;
252 Dictionary<string, Vector3> res0, res1;
257 flipTestV = Vector3.zero;
259 res0 = residueDicts[res];
260 res1 = residueDicts[res + 1];
263 success = success && res0.TryGetValue(
"CA", out ca0);
264 success = success && res0.TryGetValue(
"O", out ox0);
265 success = success && res1.TryGetValue(
"CA", out ca1);
268 Debug.Log(
"Ribbons.cs::ConstructControlPoints > Failed to get all the vectors.");
275 res0 = residueDicts[res + 1];
276 res1 = residueDicts[res + 2];
278 success = success && res0.TryGetValue(
"CA", out ca0);
279 success = success && res0.TryGetValue(
"O", out ox0);
280 success = success && res1.TryGetValue(
"CA", out ca1);
282 Debug.Log(
"Ribbons.cs::ConstructControlPoints > Failed to get all the vectors.");
303 if ( (residueDicts.Count - 1 == res) || (residueDicts.Count - 2 == res) ) {
313 res0 = residueDicts[res + 1];
314 res1 = residueDicts[res + 2];
316 success = success && res0.TryGetValue(
"CA", out ca0);
317 success = success && res0.TryGetValue(
"O", out ox0);
318 success = success && res1.TryGetValue(
"CA", out ca1);
320 Debug.Log(
"Ribbons.cs::ConstructControlPoints > Failed to get all the vectors.");
338 splineSide1.
Feval(0f, out v1);
341 splineCenter.
Feval(0f, out v1);
343 splineSide2.
Feval(0f, out v1);
344 vertices.Add(
new Vector3(v1.x, v1.y, v1.z));
346 for(ui=1; ui<=10; ui++) {
347 if(ui % uspacing == 0) {
351 splineSide1.
Feval(u, out v1);
354 splineCenter.
Feval(u, out v1);
356 splineSide2.
Feval(u, out v1);
358 vertices.Add(
new Vector3(v1.x, v1.y, v1.z));
364 Vector3 CentPoint0, CentPoint1, Sid1Point0, Sid1Point1, Sid2Point0, Sid2Point1,
365 Transversal, Tangent, Normal0, Normal1;
366 Vector3 CP0, CP1, S1P0, S1P1, S2P0, S2P1, Norm0, Norm1;
367 Vector3 leftVect0, rightVect0, leftVect1, rightVect1;
368 Vector3 Forward, LeftDiag0, RightDiag0, LeftDiag1, RightDiag1;
369 Forward = LeftDiag0 = RightDiag0 = LeftDiag1 = RightDiag1 = Vector3.zero;
370 leftVect0 = leftVect1 = rightVect0 = rightVect1 = Vector3.zero;
373 CentPoint0 = CentPoint1 = Sid1Point0 = Sid1Point1 = Sid2Point0 = Sid2Point1 = Transversal = Tangent = Normal0 = Normal1 = Vector3.zero;
374 CP0 = CP1 = S1P0 = S1P1 = S2P0 = S2P1 = Norm0 = Norm1 = Vector3.zero;
376 splineSide1.
Feval(0f, out Sid1Point1);
377 splineCenter.
Feval(0f, out CentPoint1);
378 splineSide2.
Feval(0f, out Sid2Point1);
381 splineSide2.
Deval(0f, out Tangent);
384 Transversal = Sid1Point1 - Sid2Point1;
385 Normal1 = Vector3.Cross(Transversal, Tangent);
389 float pointOneWidthFactor;
391 Vector3 leftNormal0, leftNormal1, rightNormal0, rightNormal1;
392 for(ui=1; ui<=10; ui++) {
393 if(ui % uspacing == 0) {
394 u = 0.1f * (float)ui;
395 pointOneWidthFactor = extraWidthFactor - pointOneAdjustment;
398 Sid1Point0 = Sid1Point1;
399 CentPoint0 = CentPoint1;
400 Sid2Point0 = Sid2Point1;
404 splineSide1.
Feval(u, out Sid1Point1);
405 splineCenter.
Feval(u, out CentPoint1);
406 splineSide2.
Feval(u, out Sid2Point1);
409 splineSide2.
Deval(u, out Tangent);
411 Transversal = Sid1Point1 - Sid2Point1;
412 Normal1 = Vector3.Cross(Transversal, Tangent);
416 S1P0 =
new Vector3(-Sid1Point0.x, Sid1Point0.y, Sid1Point0.z);
417 S1P1 =
new Vector3(-Sid1Point1.x, Sid1Point1.y, Sid1Point1.z);
419 S2P0 =
new Vector3(-Sid2Point0.x, Sid2Point0.y, Sid2Point0.z);
420 S2P1 =
new Vector3(-Sid2Point1.x, Sid2Point1.y, Sid2Point1.z);
422 CP0 =
new Vector3(-CentPoint0.x, CentPoint0.y, CentPoint0.z);
423 CP1 =
new Vector3(-CentPoint1.x, CentPoint1.y, CentPoint1.z);
425 Norm0 =
new Vector3(-Normal0.x, Normal0.y, Normal0.z);
426 Norm1 =
new Vector3(-Normal1.x, Normal1.y, Normal1.z);
428 leftVect0 = S1P0 - CP0;
429 leftVect1 = S1P1 - CP1;
431 rightVect0 = S2P0 - CP0;
432 rightVect1 = S2P1 - CP1;
434 leftNormal0 = leftVect0.normalized;
435 leftNormal1 = leftVect1.normalized;
437 rightNormal0 = rightVect0.normalized;
438 rightNormal1 = rightVect1.normalized;
447 LeftDiag0 = (Forward.magnitude*Forward + (leftVect0.magnitude +
ARROW_WIDTH)*leftVect0).normalized;
448 LeftDiag1 = (Forward.magnitude*Forward + (leftVect1.magnitude +
ARROW_WIDTH)*leftVect1).normalized;
449 RightDiag0 = (Forward.magnitude*Forward + (rightVect0.magnitude +
ARROW_WIDTH)*rightVect0).normalized;
450 RightDiag1 = (Forward.magnitude*Forward + (rightVect1.magnitude +
ARROW_WIDTH)*rightVect1).normalized;
454 vertices.Add(S1P0 + extraWidthFactor * leftNormal0);
457 vertices.Add(S1P1 + pointOneWidthFactor * leftNormal1);
463 triangles.Add(vIndex);
464 triangles.Add(vIndex+1);
465 triangles.Add(vIndex+2);
468 vertices.Add(S1P0 + THICKNESS * Norm0 + extraWidthFactor * leftNormal0);
471 vertices.Add(S1P1 + THICKNESS * Norm1 + pointOneWidthFactor * leftNormal1);
474 vertices.Add(CP1 + THICKNESS * Norm1);
477 triangles.Add(vIndex+3);
478 triangles.Add(vIndex+4);
479 triangles.Add(vIndex+5);
482 vertices.Add(S1P0 + extraWidthFactor * leftNormal0);
491 triangles.Add(vIndex+6);
492 triangles.Add(vIndex+7);
493 triangles.Add(vIndex+8);
496 vertices.Add(S1P0 + THICKNESS * Norm0 + extraWidthFactor * leftNormal0);
499 vertices.Add(CP1 + THICKNESS * Norm1);
502 vertices.Add(CP0 + THICKNESS * Norm0);
505 triangles.Add(vIndex+9);
506 triangles.Add(vIndex+10);
507 triangles.Add(vIndex+11);
510 vertices.Add(S2P0 + extraWidthFactor * rightNormal0);
513 vertices.Add(S2P1 + pointOneWidthFactor * rightNormal1);
519 triangles.Add(vIndex+12);
520 triangles.Add(vIndex+13);
521 triangles.Add(vIndex+14);
524 vertices.Add(S2P0 + THICKNESS * Norm0 + extraWidthFactor * rightNormal0);
527 vertices.Add(S2P1 + THICKNESS * Norm1 + pointOneWidthFactor * rightNormal1);
530 vertices.Add(CP1 + THICKNESS * Norm1);
533 triangles.Add(vIndex+15);
534 triangles.Add(vIndex+16);
535 triangles.Add(vIndex+17);
538 vertices.Add(S2P0 + extraWidthFactor * rightNormal0);
547 triangles.Add(vIndex+18);
548 triangles.Add(vIndex+19);
549 triangles.Add(vIndex+20);
553 vertices.Add(S2P0 + THICKNESS * Norm0 + extraWidthFactor * rightNormal0);
556 vertices.Add(CP1 + THICKNESS * Norm1);
559 vertices.Add(CP0 + THICKNESS * Norm0);
562 triangles.Add(vIndex+21);
563 triangles.Add(vIndex+22);
564 triangles.Add(vIndex+23);
568 vertices.Add(S1P0 + extraWidthFactor * leftNormal0);
569 normals.Add(LeftDiag0);
571 vertices.Add(S1P1 + pointOneWidthFactor * leftNormal1);
572 normals.Add(LeftDiag1);
574 vertices.Add(S2P0 + extraWidthFactor * rightNormal0);
575 normals.Add(RightDiag0);
577 vertices.Add(S2P1 + pointOneWidthFactor * rightNormal1);
578 normals.Add(RightDiag1);
581 vertices.Add(S1P0 + THICKNESS * Norm0 + extraWidthFactor * leftNormal0);
582 normals.Add(LeftDiag0);
584 vertices.Add(S1P1 + THICKNESS * Norm1 + pointOneWidthFactor * leftNormal1);
585 normals.Add(LeftDiag1);
587 vertices.Add(S2P0 + THICKNESS * Norm0 + extraWidthFactor * rightNormal0);
588 normals.Add(RightDiag0);
590 vertices.Add(S2P1 + THICKNESS * Norm1 + pointOneWidthFactor * rightNormal1);
591 normals.Add(RightDiag1);
594 triangles.Add(vIndex+24);
595 triangles.Add(vIndex+25);
596 triangles.Add(vIndex+28);
598 triangles.Add(vIndex+25);
599 triangles.Add(vIndex+28);
600 triangles.Add(vIndex+29);
602 triangles.Add(vIndex+26);
603 triangles.Add(vIndex+27);
604 triangles.Add(vIndex+30);
606 triangles.Add(vIndex+27);
607 triangles.Add(vIndex+30);
608 triangles.Add(vIndex+31);
629 extraWidthFactor = extraWidthFactor - pointOneAdjustment;
634 private void GenerateFlatRibbon(List<Vector3> vertices, List<Vector3> normals, List<int> triangles) {
635 Vector3 CentPoint0, CentPoint1, Sid1Point0, Sid1Point1, Sid2Point0, Sid2Point1,
636 Transversal, Tangent, Normal0, Normal1;
637 Vector3 CP0, CP1, S1P0, S1P1, S2P0, S2P1, Norm0, Norm1;
640 CentPoint0 = CentPoint1 = Sid1Point0 = Sid1Point1 = Sid2Point0 = Sid2Point1 = Transversal = Tangent = Normal0 = Normal1 = Vector3.zero;
641 CP0 = CP1 = S1P0 = S1P1 = S2P0 = S2P1 = Norm0 = Norm1 = Vector3.zero;
643 splineSide1.
Feval(0f, out Sid1Point1);
644 splineCenter.
Feval(0f, out CentPoint1);
645 splineSide2.
Feval(0f, out Sid2Point1);
648 splineSide2.
Deval(0f, out Tangent);
651 Transversal = Sid1Point1 - Sid2Point1;
652 Normal1 = Vector3.Cross(Transversal, Tangent);
655 Vector3 leftNormal0, leftNormal1, rightNormal0, rightNormal1;
656 for(ui=1; ui<=10; ui++) {
657 if(ui % uspacing == 0) {
658 u = 0.1f * (float)ui;
661 Sid1Point0 = Sid1Point1;
662 CentPoint0 = CentPoint1;
663 Sid2Point0 = Sid2Point1;
667 splineSide1.
Feval(u, out Sid1Point1);
668 splineCenter.
Feval(u, out CentPoint1);
669 splineSide2.
Feval(u, out Sid2Point1);
672 splineSide2.
Deval(u, out Tangent);
674 Transversal = Sid1Point1 - Sid2Point1;
675 Normal1 = Vector3.Cross(Transversal, Tangent);
680 S1P0 =
new Vector3(-Sid1Point0.x, Sid1Point0.y, Sid1Point0.z);
681 S1P1 =
new Vector3(-Sid1Point1.x, Sid1Point1.y, Sid1Point1.z);
683 S2P0 =
new Vector3(-Sid2Point0.x, Sid2Point0.y, Sid2Point0.z);
684 S2P1 =
new Vector3(-Sid2Point1.x, Sid2Point1.y, Sid2Point1.z);
686 CP0 =
new Vector3(-CentPoint0.x, CentPoint0.y, CentPoint0.z);
687 CP1 =
new Vector3(-CentPoint1.x, CentPoint1.y, CentPoint1.z);
689 Norm0 =
new Vector3(-Normal0.x, Normal0.y, Normal0.z);
690 Norm1 =
new Vector3(-Normal1.x, Normal1.y, Normal1.z);
694 leftNormal0 = (S1P0 - CP0).normalized;
695 leftNormal1 = (S1P1 - CP1).normalized;
697 rightNormal0 = (S2P0 - CP0).normalized;
698 rightNormal1 = (S2P1 - CP1).normalized;
710 triangles.Add(vIndex);
711 triangles.Add(vIndex+1);
712 triangles.Add(vIndex+2);
715 vertices.Add(S1P0 + THICKNESS * Norm0);
718 vertices.Add(S1P1 + THICKNESS * Norm1);
721 vertices.Add(CP1 + THICKNESS * Norm1);
724 triangles.Add(vIndex+3);
725 triangles.Add(vIndex+4);
726 triangles.Add(vIndex+5);
738 triangles.Add(vIndex+6);
739 triangles.Add(vIndex+7);
740 triangles.Add(vIndex+8);
743 vertices.Add(S1P0 + THICKNESS * Norm0);
746 vertices.Add(CP1 + THICKNESS * Norm1);
749 vertices.Add(CP0 + THICKNESS * Norm0);
752 triangles.Add(vIndex+9);
753 triangles.Add(vIndex+10);
754 triangles.Add(vIndex+11);
766 triangles.Add(vIndex+12);
767 triangles.Add(vIndex+13);
768 triangles.Add(vIndex+14);
771 vertices.Add(S2P0 + THICKNESS * Norm0);
774 vertices.Add(S2P1 + THICKNESS * Norm1);
777 vertices.Add(CP1 + THICKNESS * Norm1);
780 triangles.Add(vIndex+15);
781 triangles.Add(vIndex+16);
782 triangles.Add(vIndex+17);
794 triangles.Add(vIndex+18);
795 triangles.Add(vIndex+19);
796 triangles.Add(vIndex+20);
799 vertices.Add(S2P0 + THICKNESS * Norm0);
802 vertices.Add(CP1 + THICKNESS * Norm1);
805 vertices.Add(CP0 + THICKNESS * Norm0);
808 triangles.Add(vIndex+21);
809 triangles.Add(vIndex+22);
810 triangles.Add(vIndex+23);
815 normals.Add(leftNormal0);
818 normals.Add(leftNormal1);
821 normals.Add(rightNormal0);
824 normals.Add(rightNormal1);
827 vertices.Add(S1P0 + THICKNESS * Norm0);
828 normals.Add(leftNormal0);
830 vertices.Add(S1P1 + THICKNESS * Norm1);
831 normals.Add(leftNormal1);
833 vertices.Add(S2P0 + THICKNESS * Norm0);
834 normals.Add(rightNormal0);
836 vertices.Add(S2P1 + THICKNESS * Norm1);
837 normals.Add(rightNormal1);
840 triangles.Add(vIndex+24);
841 triangles.Add(vIndex+25);
842 triangles.Add(vIndex+28);
844 triangles.Add(vIndex+25);
845 triangles.Add(vIndex+28);
846 triangles.Add(vIndex+29);
848 triangles.Add(vIndex+26);
849 triangles.Add(vIndex+27);
850 triangles.Add(vIndex+30);
852 triangles.Add(vIndex+27);
853 triangles.Add(vIndex+30);
854 triangles.Add(vIndex+31);
861 private List<int>
Copy(List<int> l) {
862 List<int> result =
new List<int>();
872 if(residueDicts.Count == 0)
874 int[] ssarray =
new int[residueDicts.Count];
875 int[] handedarray =
new int[residueDicts.Count];
888 Debug.Log (
"Use info from pdb: " + createss);
892 ssarray = sslist.ToArray();
893 handedarray = handedlist.ToArray();
896 if(!mustSplitDictList) {
901 Debug.Log(
"Ribbons.cs::CreateRibons() > Splitting");
904 List<Dictionary<string, Vector3>> tmpDictList =
new List<Dictionary<string, Vector3>>();
905 List<int> tmpHandednessList =
new List<int> ();
906 List<int> tmpSSList =
new List<int>();
910 while(resNb<residueDicts.Count && splits.Count>0) {
912 if(resNb != splits[0]){
915 tmpDictList.Add(residueDicts[resNb]);
916 if(ssarray.Length != 0){
917 tmpSSList.Add (ssarray[resNb]);
918 tmpHandednessList.Add (handedarray[resNb]);
922 Debug.Log(
"Splitting at ResNB: " + resNb.ToString());
926 tmpHandednessList.Clear ();
932 if(tmpDictList.Count > 0 && tmpSSList.Count > 0)
936 private void CreateRibbons(List<Dictionary<string, Vector3>> residueDicts, List<int> sslist, List<int >handedlist) {
939 List<Vector3> vertices0 =
new List<Vector3>();
940 List<Vector3> vertices1 =
new List<Vector3>();
941 List<Vector3> vertices2 =
new List<Vector3>();
944 List<Vector3> vertices =
new List<Vector3>();
945 List<Color32> colors =
new List<Color32>();
946 List<Vector3> normals =
new List<Vector3>();
948 switch(RIBBON_DETAIL) {
963 flipTestV =
new Vector3();
964 splineSide1 =
new BSpline(
false);
965 splineCenter =
new BSpline(
false);
966 splineSide2 =
new BSpline(
false);
968 int[] ss =
new int[residueDicts.Count];
969 int[] handedness =
new int[residueDicts.Count];
970 List<int> ssglic =
new List<int> ();
971 int nbRes = residueDicts.Count;
972 int colorOffset = nbRes - 1;
976 ss = sslist.ToArray ();
977 handedness = handedlist.ToArray ();
980 nbRes = residueDicts.Count;
983 colorOffset = nbRes - 1;
987 for (
int i=1; i<nbRes-1; i++) {
988 if (ss [i - 1] == HELIX && ss [i + 1] == HELIX)
990 if (ss [i - 1] == STRAND && ss [i + 1] == STRAND)
997 List<int> triangles =
new List<int>();
1000 for(
int i=0; i<nbRes; i++) {
1003 int colorIndex = (i+colorOffset) % nbRes;
1005 isArrow = (ss[colorIndex] == STRAND && ( (colorIndex+1 == nbRes) || (ss[colorIndex+1] != STRAND) ));
1007 if(RENDER_MODE == 0) {
1012 if (isArrow && ARROW_WIDTH > 0f)
1026 switch(ss[colorIndex]) {
1028 color = HELIX_COLOR.
color;
1031 color = STRAND_COLOR.
color;
1034 color = COIL_COLOR.
color;
1038 for(
int j=0; j<320; j++)
1045 if(RENDER_MODE == 0) {
1061 List<float[]> helixlist =
new List<float[]> ();
1063 for (
int i = 0; i < helix.Count; i++) {
1065 helixlist.Add (helix [i]);
1069 if(helixlist.Count != 0)
1070 helixlist.Add (helixlist[helixlist.Count - 1]);
1082 List<float[]> strandlist =
new List<float[]> ();
1084 for (
int i = 0; i < strand.Count; i++) {
1086 strandlist.Add (strand [i]);
1097 for (
int i = 0; i < reschain.Count; i++) {
1098 if(reschain[i] == chain)
1107 for (
int i = 0; i < tmpstrandlist.Count; i++) {
1108 for(
int j = i; j < tmpstrandlist.Count; j++){
1109 if(tmpstrandlist[j][0] < tmpstrandlist[i][0]){
1110 float[] tmp = tmpstrandlist[i];
1111 tmpstrandlist[i] = tmpstrandlist[j];
1112 tmpstrandlist[j] = tmp;
1119 while (index < tmpstrandlist.Count - 1)
1121 if (tmpstrandlist[index][0] == tmpstrandlist[index + 1][0])
1122 tmpstrandlist.RemoveAt(index);
1127 tmpstrandlist.Add (tmpstrandlist [tmpstrandlist.Count - 1]);
1128 return tmpstrandlist;
1138 private void CreateSSlist( ref List<int> sslist, ref List<int> handednesslist){
1144 List<float[]> tmplisthelix2 =
FindHelix(chain);
1145 List<float[]> tmpliststrand2 =
FindStrand(chain);
1147 List<float[]> tmpliststrand =
new List<float[]>();
1148 List<float[]> tmplisthelix =
new List<float[]>();
1151 if (tmpliststrand2.Count != 0)
1155 float[] b =
new float[2];
1158 tmpliststrand.Add(b);
1161 if (tmplisthelix2.Count != 0){
1162 tmplisthelix = tmplisthelix2;
1164 float[] b =
new float[4];
1169 tmplisthelix.Add(b);
1173 for(
int j = firstresnb; j<nbres+
firstresnb; j++){
1174 if(j >= tmpliststrand[0][0] && j < tmpliststrand[0][1]){
1176 handednesslist.Add (RHANDED);
1178 else if(j == tmpliststrand[0][1]){
1180 handednesslist.Add (RHANDED);
1181 tmpliststrand.RemoveAt(0);
1183 else if(j >= tmplisthelix[0][0] && j < tmplisthelix[0][1]){
1186 handednesslist.Add (RHANDED);
1188 handednesslist.Add (LHANDED);
1190 else if(j == tmplisthelix[0][1]){
1192 handednesslist.Add (RHANDED);
1193 tmplisthelix.RemoveAt(0);
1197 handednesslist.Add (RHANDED);
1201 sslist.RemoveAt (0);
1202 handednesslist.RemoveAt (0);
1209 ss_chain_col =
new Dictionary <string, Color32> ();
1213 ss_chain_col.Add (
"A", ChainColorA.
color);
1214 ss_chain_col.Add (
"AL",
new Color32( 50, 50, 100, 255));
1215 ss_chain_col.Add (
"B", ChainColorB.
color);
1216 ss_chain_col.Add (
"BL",
new Color32(60, 120, 60, 255));
1217 ss_chain_col.Add (
"C", ChainColorC.
color);
1218 ss_chain_col.Add (
"CL",
new Color32(50, 90, 90, 255));
1219 ss_chain_col.Add (
"D", ChainColorD.
color);
1220 ss_chain_col.Add (
"DL",
new Color32(60, 150, 60, 255));
1221 ss_chain_col.Add (
"E", ChainColorE.
color);
1222 ss_chain_col.Add (
"EL",
new Color32(60, 150, 150, 255));
1227 Color32 value =
new Color32(255, 255, 255, 255);
1228 if(ss_chain_col == null)
1229 return new Color32(255, 255, 255, 255);
1230 else if(!ss_chain_col.TryGetValue(type, out value))
1231 return new Color32(255, 255, 255, 255);
1233 return ss_chain_col[type];
void AddControlPoints(Vector3 ca0, Vector3 ox0, Vector3 ca1, int ss, int handedness)
void ShiftBSplineCPoints()
static List< Dictionary< string, Vector3 > > residueDictionaries
static ColorObject ChainColorD
static bool ssDivCol
When true, triggers the per domain coloring.
void GetCPoint(int n, out Vector3 p)
static List< string > resChainList2
The chain of each residue.
void Deval(float t, out Vector3 d)
void GenerateSpline(int n, List< Vector3 > vertices)
static ColorObject ChainColorB
void CopyCPoints(int n_source, int n_dest)
static Dictionary< string, Color32 > ss_chain_col
static float[] ribbonWidth
static bool ssColChain
When true, triggers the per chain secondary structure coloring.
void CreateRibbons(List< Dictionary< string, Vector3 >> residueDicts, List< int > sslist, List< int >handedlist)
static ColorObject COIL_COLOR
float CalculateTorsionalAngle(Vector3 at0, Vector3 at1, Vector3 at2, Vector3 at3, bool print)
static List< string > helixChainList
The helix chain list (extract from the pdb).
List< float[]> FindStrand(string chain)
Find strands by chain in ssStrandList (informations from the pdb file).
static ColorObject ChainColorC
List< float[]> FindHelix(string chain)
Finds helices by chain in ssHelixList (informations from the pdb file).
List< float[]> SortStrand(List< float[]> tmpstrandlist)
void ShiftControlPoints()
static void GenerateMeshes(List< Vector3 > vertices, List< Vector3 > normals, List< int > triangles, List< Color32 > colors, int[] ss, string tag="RibbonObj", string gameobj="Ribbons")
static ColorObject ChainColorA
static List< int > splits
Terminal residue number of each subunits.
int ComputeNbRes(string chain)
static bool mustSplitDictList
static List< float[]> ssStrandList
First and last residue of each strand (extract from the pdb) float[0] is the first residue of each st...
static List< float[]> ssHelixList
List of informations about each helix (extract from the pdb) float[0] is the first residue of each he...
!WiP Includes FLAGS of GUI.
static Color32 GetColorChain(string type)
static ColorObject STRAND_COLOR
void ConstructControlPoints(List< Dictionary< string, Vector3 >> residueDicts, int res, int ss, int handedness)
void CalculateSecondaryStructures(List< Dictionary< string, Vector3 >> residueDicts, int[] ss, int[] handedness)
void CreateSSlist(ref List< int > sslist, ref List< int > handednesslist)
Creates secondary structure list and handedness list using ss informations from the pdb file...
void GenerateFlatRibbon(List< Vector3 > vertices, List< Vector3 > normals, List< int > triangles)
static List< string > existingChain
List of the chains existing in the molecule.
static ColorObject ChainColorE
static string currentchain
void GenerateArrowRibbon(List< Vector3 > vertices, List< Vector3 > normals, List< int > triangles)
void SetCPoint(int n, Vector3 p)
Vector3 LinearComb(float scalar0, Vector3 vector0, float scalar1, Vector3 vector1)
static int firstresnb
First residue number in pdb.
static List< string > strandChainList
The strand chain list (extract from the pdb).
void Feval(float t, out Vector3 p)
List< int > Copy(List< int > l)
float WeirdDistance(float x1, float y1, float x2, float y2)
static ColorObject HELIX_COLOR