src/org/gel/mauve/dcj/DCJ.java

Go to the documentation of this file.
00001 package org.gel.mauve.dcj;
00002 
00003 import java.util.*;
00004 import java.io.*;
00010 public class DCJ {
00011 
00012         /***************************************************************************
00013          * Synteny Block object holds Vertices left,right, value of genomeA and
00014          * value of genome B performs traversing along black lines to print state of
00015          * genome A
00016          **************************************************************************/
00017         class SB {
00018                 private Vert left; // left vert
00019 
00020                 private Vert right; // right vert
00021 
00022                 private String identity;
00023 
00024                 private int valueA; // int value for genome A
00025 
00026                 private int valueB; // int value for genome B
00027 
00028                 private boolean visited = false;
00029 
00030                 // default constructor
00031                 public SB () {
00032                         left = null;
00033                         right = null;
00034                         identity = "";
00035                 }// end SB constructor
00036 
00037                 public SB (Vert l, Vert r, String i) {
00038                         left = l;
00039                         right = r;
00040                         identity = i;
00041                         l.setSB (this);
00042                         r.setSB (this);
00043                 }// end SB constructor
00044 
00045                 public SB (Vert l, Vert r) {
00046                         left = l;
00047                         right = r;
00048                         identity = "[" + l.getGene () + " " + r.getGene () + "]";
00049                         l.setSB (this);
00050                         r.setSB (this);
00051                 }// end SB constructor
00052 
00053                 // mutator methods
00054                 public void setVisited (boolean b) {
00055                         this.visited = b;
00056                 }
00057 
00058                 public void setLeft (Vert v) {
00059                         this.left = v;
00060                 }
00061 
00062                 public void setRight (Vert v) {
00063                         this.right = v;
00064                 }
00065 
00066                 public void setIdentity (String s) {
00067                         this.identity = s;
00068                 }
00069 
00070                 public void turnValue (int s) {
00071                         this.valueA = s;
00072                         // {try{this.valueA=Integer.parseInt(s);}catch(Exception
00073                         // e){System.out.println("format error\n"+e);System.exit(0);}
00074                 }
00075 
00076                 public void setValueA (int i) {
00077                         this.valueA = i;
00078                 }
00079 
00080                 public void setValueB (int i) {
00081                         this.valueB = i;
00082                 }
00083 
00084                 // //newly constructed vertices need to be set to point to this SB.
00085                 public boolean setVertPointers () {
00086                         if (this.getLeft () == null || this.getRight () == null) {
00087                                 return false;
00088                         } else {
00089                                 this.getLeft ().setSB (this);
00090                                 this.getRight ().setSB (this);
00091                         }
00092                         return true;
00093                 }
00094 
00095                 // //retrieval methods
00096                 public boolean wasVisited () {
00097                         return this.visited;
00098                 }
00099 
00100                 public Vert getLeft () {
00101                         return this.left;
00102                 }
00103 
00104                 public Vert getRight () {
00105                         return this.right;
00106                 }
00107 
00108                 public String getIdentity () {
00109                         return this.identity;
00110                 }
00111 
00112                 public int getValueA () {
00113                         return this.valueA;
00114                 }
00115 
00116                 public int getValueB () {
00117                         return this.valueB;
00118                 }
00119 
00120                 // //polarity of the SB, pos value head is right Vert, neg value head is
00121                 // left Vert.
00122                 public Vert getHeadA () {
00123                         if (this.getValueA () < 0) {
00124                                 return this.getLeft ();
00125                         } else {
00126                                 return this.getRight ();
00127                         }
00128                 }
00129 
00130                 public Vert getTailA () {
00131                         if (this.getValueA () < 0) {
00132                                 return this.getRight ();
00133                         } else {
00134                                 return this.getLeft ();
00135                         }
00136                 }
00137 
00138                 public Vert getHeadB () {
00139                         // if(this.getValueB()<0){return this.getLeft();}else{return
00140                         // this.getRight();}
00141                         if (this.getValueB () == this.getValueA ()) {
00142                                 return this.getRight ();
00143                         } else {
00144                                 return this.getLeft ();
00145                         }
00146                 }
00147 
00148                 public Vert getTailB () {
00149                         // if(this.getValueB()<0){return this.getRight();} else{return
00150                         // this.getLeft();}
00151                         if (this.getValueB () == this.getValueA ()) {
00152                                 return this.getLeft ();
00153                         } else {
00154                                 return this.getRight ();
00155                         }
00156                 }
00157 
00158         }// end SB
00159 
00160         /***************************************************************************
00161          * Class Vert for Vertices Every SB has a left and right Vert Vert contains
00162          * Variables black and grey which point to other Verts
00163          **************************************************************************/
00164         class Vert {
00165                 private Vert black; // black line
00166 
00167                 private Vert grey; // grey arc
00168 
00169                 private SB sb; // point to parent SB
00170 
00171                 private String gene; // name the Vert
00172 
00173                 private String isCap; // name the cap ie. A1 A2 B1 B2...
00174 
00175                 private String chromosome; // currently not used
00176 
00177                 private boolean seenCap;// quick fix to know what caps were
00178 
00179                 // visited for closing AA,AB, and BB paths
00180                 // constructor
00181                 public Vert () {
00182                         black = null;
00183                         grey = null;
00184                         sb = null;
00185                         gene = "";
00186                         chromosome = "";
00187                         isCap = "";
00188                         seenCap = false;
00189                 }// end Vert constructor
00190 
00191                 // Vert constructor, doesn't assign SB
00192                 public Vert (Vert b, Vert g, String s) {
00193                         this.black = b;
00194                         this.grey = g;
00195                         this.gene = s;
00196                         sb = null;
00197                         chromosome = "";
00198                         isCap = "";
00199                         seenCap = false;
00200                 }
00201 
00202                 public Vert (String s) {
00203                         this.black = null;
00204                         this.grey = null;
00205                         this.gene = s;
00206                         sb = null;
00207                         chromosome = "";
00208                         isCap = "";
00209                         seenCap = false;
00210                 }
00211 
00212                 // MUTATOR methods
00213                 public void setBlack (Vert v) {
00214                         this.black = v;
00215                 }
00216 
00217                 public void setGrey (Vert v) {
00218                         this.grey = v;
00219                 }
00220 
00221                 public void setSB (SB s) {
00222                         this.sb = s;
00223                 }
00224 
00225                 public void setGene (String s) {
00226                         this.gene = s;
00227                 }
00228 
00229                 // name the chromosome the vertex belongs to
00230                 public void setChromosome (String s) {
00231                         this.chromosome = s;
00232                 }
00233 
00234                 // name the cap
00235                 public void setIsCap (String b) {
00236                         this.isCap = b;
00237                 }
00238 
00239                 // cap a vertex, true is A cap(black line), false is B cap (grey line)
00240                 public void setSeen (boolean b) {
00241                         this.seenCap = b;
00242                 }
00243 
00244                 // generates a new Vert object that has the profile of a cap.
00245                 public Vert cap (boolean b) {
00246                         Vert newcap;
00247                         if (b) {
00248                                 newcap = new Vert ("A");
00249                                 newcap.setIsCap (newcap.getGene ());
00250                                 newcap.setSB (new SB ());
00251                                 newcap.setBlack (newcap);
00252                                 newcap.setGrey (newcap);
00253                                 this.joinBlack (newcap);
00254                                 newcap.setGene ("" + newcap.getGene () + (++counta));
00255                         } else {
00256                                 newcap = new Vert ("B");
00257                                 newcap.setIsCap (newcap.getGene ());
00258                                 newcap.setSB (new SB ());
00259                                 newcap.setBlack (newcap);
00260                                 newcap.setGrey (newcap);
00261                                 this.joinGrey (newcap);
00262                                 newcap.setGene ("" + newcap.getGene () + (++countb));
00263                         }
00264                         return newcap;
00265                 }
00266 
00267                 // retrieval methods
00268                 public String getGene () {
00269                         return this.gene;
00270                 }
00271 
00272                 public Vert getBlack () {
00273                         return this.black;
00274                 }
00275 
00276                 public Vert getGrey () {
00277                         return this.grey;
00278                 }
00279 
00280                 public SB getSB () {
00281                         return this.sb;
00282                 }
00283 
00284                 public String getCap () {
00285                         return this.isCap;
00286                 }
00287 
00288                 public boolean isCap () {
00289                         return ((this.getCap ()).length () > 0);
00290                 }
00291 
00292                 public String getChromosome () {
00293                         return this.chromosome;
00294                 }
00295 
00296                 public boolean seen () {
00297                         return this.seenCap;
00298                 }
00299 
00300                 // print methods
00301                 // prints the main variables of Vert, try-catch for events where vars
00302                 // have not been initialized.
00303                 public void printMe () {
00304                         buf.append ("Block: ");
00305                         try {
00306                                 buf.append (this.getGene ());
00307                         } catch (Exception e) {
00308                         }
00309                         buf.append ("   black:");
00310 
00311                         try {
00312                                 buf.append (this.getBlack ().getGene ());
00313                         } catch (Exception e) {
00314                         }
00315                         buf.append ("   Grey: ");
00316 
00317                         try {
00318                                 buf.append (this.getGrey ().getGene ());
00319                         } catch (Exception e) {
00320                         }
00321                         buf.append ("   SB: ");
00322 
00323                         try {
00324                                 buf.append (this.getSB ().getIdentity ());
00325                         } catch (Exception e) {
00326                         }
00327                         if (this.isCap ()) {
00328                                 buf.append ("   cap:" + this.getCap ());
00329                         }
00330                         buf.append ("\n");
00331                 }
00332 
00333                 // traverse capped genome with alternating black/grey paths (for closing
00334                 // paths to generate HP cycle) and returns the end cap
00335                 public Vert traversePath (boolean b) {
00336                         if (this.isCap ())
00337                                 return this;
00338                         if (b)
00339                                 return this.getBlack ().traversePath (false);
00340                         return this.getGrey ().traversePath (true);
00341                 }
00342 
00343                 // overloaded method, same as previous but populates a vector
00344                 public Vert traversePath (boolean b, Vector v) {
00345                         // this.printMe();
00346                         // populate greyVector (vector of grey lines)
00347                         if (!b) {
00348                                 v.addElement (this);
00349                         }
00350                         if (this.isCap ())
00351                                 return this;
00352                         if (b)
00353                                 return this.getBlack ().traversePath (false, v);
00354                         return this.getGrey ().traversePath (true, v);
00355                 }
00356 
00357                 // this = a = cap, b is another cap. closepath forms a cycle, the method
00358                 // depends on the Cap values (A&B A&A or B&B)
00359                 public void closePath (Vert b) {
00360                         // a and b are both B caps
00361                         if ((this.getCap ().equals (b.getCap ()))
00362                                         && (this.getCap ().equals ("B"))) {
00363                                 this.joinBlack (b);
00364                         }
00365                         // a and b are both A caps
00366                         if ((this.getCap ().equals (b.getCap ()))
00367                                         && (this.getCap ().equals ("A"))) {
00368                                 this.joinGrey (b);
00369                         }
00370                         // a!=b and a is an A cap (black line out)
00371                         if (!(this.getCap ().equals (b.getCap ()))
00372                                         && this.getCap ().equals ("A")) {
00373                                 this.setGrey (b.getGrey ());
00374                                 (b.getGrey ()).setGrey (this);
00375                         }
00376                         // a!=b and a is a B cap (grey line out) - is reverse of above code
00377                         if (!(this.getCap ().equals (b.getCap ()))
00378                                         && this.getCap ().equals ("B")) {
00379                                 b.setGrey (this.getGrey ());
00380                                 (this.getGrey ()).setGrey (b);
00381                         }
00382                 }// end closepath
00383 
00384                 // used in DCJ moves and joining caps to form cycles
00385                 public void joinBlack (Vert b) {
00386                         this.setBlack (b);
00387                         b.setBlack (this);
00388                 }
00389 
00390                 // used in joining two B caps to form cycles
00391                 public void joinGrey (Vert b) {
00392                         this.setGrey (b);
00393                         b.setGrey (this);
00394                 }// end joinGrey
00395 
00396                 // tests if the Vert exists as a 1-cycle. Which is characterized as a
00397                 // black and grey line pointing to the same Gene
00398                 public boolean isOneCycle () {
00399                         return (this.grey == this.black);
00400                 }
00401 
00402         }// end Vert
00403 
00404         // ////////////////////////////////////////////////////////////////////////////
00405         // ////////////////////////////////////////////////////////////////////////////
00406         // ////////////////////////////////////////////////////////////////////////////
00407         /***************************************************************************
00408          * Class DCJ Loads the data and parses Creates and populates Vectors for SBs
00409          * and grey lines in the process.
00410          **************************************************************************/
00411         public int counta = 0;
00412 
00413         public int countb = 0;
00414 
00415         public int countDCJ = 0;
00416 
00417         public int bufsize = 256;
00418 
00419         public StringBuffer buf; // buffer holding log output
00420 
00421         public StringBuffer opBuf; // operation buffer
00422 
00423         public boolean suppress = false;
00424 
00425         String speciesA = "";
00426 
00427         String speciesB = "";
00428 
00429         Vector capVector;
00430 
00431         Vector sbVector;
00432 
00433         Vector greyVector;
00434 
00435         public DCJ () {
00436                 this.capVector = new Vector ();
00437                 this.sbVector = new Vector ();
00438                 greyVector = new Vector ();
00439                 buf = new StringBuffer (bufsize);
00440         }
00441 
00442         public DCJ (StringTokenizer A, StringTokenizer B) {
00443                 buf = new StringBuffer (bufsize);
00444                 opBuf = new StringBuffer ();
00445                 this.capVector = new Vector ();
00446                 this.sbVector = new Vector ();
00447                 greyVector = new Vector ();
00448                 loadGenome (A, B);
00449                 this.printSBV ();
00450                 this.cycleDCJ ();
00451 
00452         }
00453 
00454         public DCJ (StringTokenizer A, StringTokenizer B, String species1,
00455                         String species2) {
00456                 buf = new StringBuffer (bufsize);
00457                 opBuf = new StringBuffer ();
00458                 speciesA = species1;
00459                 speciesB = species2;
00460                 this.capVector = new Vector ();
00461                 this.sbVector = new Vector ();
00462                 greyVector = new Vector ();
00463                 loadGenome (A, B);
00464                 this.printSBV ();
00465                 this.cycleDCJ ();
00466 
00467         }
00468 
00469         public void cycleDCJ () {
00470                 Vert temp;
00471                 if (!suppress)
00472                         buf.append (greyVector.size () + " Grey lines\n");
00473                 this.printSBBlack ();
00474                 while (greyVector.size () > 0) {
00475                         temp = (Vert) greyVector.firstElement ();
00476                         if (this.DCJ (temp)) {
00477                                 if (!suppress) {
00478                                         this.printSBBlack ();
00479                                 }
00480                         }
00481                 }// end while
00482                 if (suppress)
00483                         buf.append (countDCJ + "        \n");
00484         }
00485 
00486         public String getLog () {
00487                 return this.buf.toString ();
00488         }
00489 
00490         public String getOpBuf () {
00491                 return this.opBuf.toString ();
00492         }
00493 
00494         // takes an sbArray which is the SB vector converted into an array
00495         // String s is genome B that is tokenized and parsed into an array
00496         // of integers
00497         // genome B values are empty and are set using intArray values.
00498         // grey arcs are they formed from head to tail
00499         // caps are then formed on both ends
00500         // run time is O(n) n=size of s.
00501 
00502         public int getCount () {
00503                 return countDCJ;
00504         }
00505 
00506         // DCJ operation. 4 verts for v.DCJ(): v, v.black, v.grey, and v.black.grey
00507         public boolean DCJ (Vert v) {
00508                 StringBuffer tempbuf = new StringBuffer ();
00509                 // check for 1 cycle first, if it is, delete and move on
00510                 // check because a previous call may have generated 2 1-cycles.
00511                 if (v.isOneCycle ()) {
00512                         // code for removing 1-cycle from Vector of lines, this 1-cycle is
00513                         // formed from a previous call that was a 2-cycle forked into 2
00514                         // 1-cycles, it is not counted as a DCJ call
00515                         // remove(object) from a vector is O(n) time however since the
00516                         // object is always the first object, it's constant.
00517                         this.greyVector.remove (v);
00518                 } else {
00519                         // don't mess with the following orders
00520                         // v.black -join- v.grey.black
00521                         ++countDCJ;
00522                         if (!suppress) {
00523                                 tempbuf
00524                                                 .append (countDCJ
00525                                                                 + " JOIN: "
00526                                                                 + v.getBlack ().getBlack ().getGene ()
00527                                                                 + " to "
00528                                                                 + v.getGrey ().getBlack ().getBlack ()
00529                                                                                 .getGene () + " ");
00530                         }
00531                         v.getBlack ().joinBlack (v.getGrey ().getBlack ());
00532                         // v -join- v.grey, this will always form a 1-cycle
00533                         if (!suppress) {
00534                                 tempbuf.append ("JOIN: " + v.getBlack ().getGene () + " to "
00535                                                 + v.getGrey ().getBlack ().getGene () + "\n");
00536                         }
00537                         v.joinBlack (v.getGrey ());
00538                         this.greyVector.remove (this); // remove The 1-cycle formed from
00539                         // the DCJ
00540                         buf.append (tempbuf.toString ());
00541                         opBuf.append (tempbuf.toString ());
00542                         return true;
00543                 }
00544                 buf.append (tempbuf.toString ());
00545                 opBuf.append (tempbuf.toString ());
00546                 return false;
00547         }// end DCJ
00548 
00549         public void parseAndLoadGrey (String s, SB [] sbArray) {
00550                 int [] intArray = this.toIntArray (s);
00551                 int count = 0;
00552                 // use intArray[] to manipulate existing objects in sbArray[] (join
00553                 // grey)
00554                 for (int i = 0; i < intArray.length - 1; i++) {
00555                         sbArray[Math.abs (intArray[i]) - 1].setValueB (intArray[i]);
00556                         sbArray[Math.abs (intArray[i + 1]) - 1].setValueB (intArray[i + 1]);
00557                         sbArray[Math.abs (intArray[i]) - 1].getHeadB ().joinGrey (
00558                                         sbArray[Math.abs (intArray[i + 1]) - 1].getTailB ());
00559                         // sbArray[Math.abs(intArray[i])-1].getRight().joinGrey(sbArray[Math.abs(intArray[i+1])-1].getLeft());
00560 
00561                 }// end for
00562                 capVector.add (sbArray[Math.abs (intArray[0]) - 1].getTailB ().cap (
00563                                 false));
00564                 capVector.add (sbArray[Math.abs (intArray[intArray.length - 1]) - 1]
00565                                 .getHeadB ().cap (false));
00566         }
00567 
00568         // parses string s, adds a capped sb vector with black lines
00569         // connected to global vector, and populates the cap vector.
00570         // This method would have to be called k times where k is the number of
00571         // chromosomes. run time of O(n)
00572         public void parseAndLoadBlack (String s) {
00573                 StringTokenizer token = new StringTokenizer (s);
00574                 String tempInt; // for parsed strings of s
00575                 SB tempSB; // temp SB
00576                 Vector tempSbVector = new Vector (); // vector of SBs that're created
00577                 while (token.hasMoreTokens ()) {
00578                         tempInt = token.nextToken ().trim ();
00579                         tempSB = new SB (new Vert (tempInt + "L"), new Vert (tempInt + "R"));
00580                         tempSB.setVertPointers ();
00581                         tempSB.turnValue (Integer.parseInt (tempInt));
00582                         tempSbVector.add (tempSB);
00583                         // System.out.print(tempInt+" ");
00584                 }// end while
00585                 for (int i = 0; i < tempSbVector.size () - 1; i++) {
00586                         // CONNECT black lines
00587                         ((SB) tempSbVector.elementAt (i)).getRight ().joinBlack (
00588                                         ((SB) tempSbVector.elementAt (i + 1)).getLeft ());
00589                 }// end for
00590                 // add A Caps to front and end of chromosome
00591                 capVector.add ((((SB) tempSbVector.firstElement ()).getLeft ())
00592                                 .cap (true));
00593                 capVector.add ((((SB) tempSbVector.lastElement ()).getRight ())
00594                                 .cap (true));
00595 
00596                 this.sbVector.addAll (tempSbVector);
00597         }// end parseAndLoadBlack
00598 
00599         /***************************************************************************
00600          * traverses the genome starting from caps from the cap vector checks if the
00601          * caps have been visited, if visited it passes it otherwise it calls
00602          * traversePath from class Vert. Then it closes the path from the start cap
00603          * to the end cap. At this point the genome data structure is complete And
00604          * lastly, it populates the grey vector by iterating through the SB Vector
00605          * and adding all grey lines.
00606          **************************************************************************/
00607         public void traverseAndClose () {
00608                 Vector dump = new Vector (); // dump for visited verts
00609                 Vector greybin = new Vector ();
00610                 Vert start;
00611                 Vert end;
00612                 for (int i = 0; i < this.capVector.size (); i++) {
00613                         start = (Vert) this.capVector.elementAt (i);
00614                         if (!start.seen ()) {
00615                                 if (start.getCap ().equals ("A")) {
00616                                         // start.printMe();
00617                                         end = start.getBlack ().traversePath (false, greybin);
00618                                 } else { // is a B cap
00619                                         greybin.add (start.getGrey ());
00620                                         end = start.getGrey ().traversePath (true, greybin);
00621                                 }
00622                                 start.setSeen (true);
00623                                 end.setSeen (true);
00624                                 start.closePath (end);
00625                                 dump.add (start);
00626                         }// end if
00627                 }// end for
00628                 // this.greyVector=greybin;
00629                 SB tempSB;
00630                 for (int i = 0; i < sbVector.size (); i++) {
00631                         tempSB = (SB) sbVector.elementAt (i);
00632                         greyVector.add (tempSB.getLeft ().getGrey ());
00633                         greyVector.add (tempSB.getRight ().getGrey ());
00634                 }
00635 
00636                 // this.capVector=dump;
00637         }// end traverseAndClose
00638 
00639         // generates an Array of SB Vector of size 0 to Max Value of genome.
00640         public SB [] toSBArray () {
00641                 SB [] sbArray;
00642                 SB tempSB;
00643                 int max = 0; // max value of genes for array size
00644                 for (Enumeration e = this.sbVector.elements (); e.hasMoreElements ();) {
00645                         tempSB = (SB) e.nextElement ();
00646                         if (max < Math.abs (tempSB.getValueA ()))
00647                                 max = Math.abs (tempSB.getValueA ());
00648                 }
00649                 sbArray = new SB [max];// size of array
00650                 // load SB array indexed on gene values
00651                 for (Enumeration e = this.sbVector.elements (); e.hasMoreElements ();) {
00652                         tempSB = (SB) e.nextElement ();
00653                         sbArray[Math.abs (tempSB.getValueA ()) - 1] = tempSB;
00654                 }
00655                 return sbArray;
00656         }
00657 
00658         public int [] toIntArray (String s) {
00659                 StringTokenizer token = new StringTokenizer (s);
00660                 int intArray[] = new int [token.countTokens ()];
00661                 int count = 0;
00662                 while (token.hasMoreTokens ()) {
00663                         intArray[count++] = (Integer.parseInt (token.nextToken ()));
00664                 }// end while hasMoreTokens
00665                 return intArray;
00666         }// end toSBArray
00667 
00668         public void loadGenome (StringTokenizer tokenA, StringTokenizer tokenB) {
00669                 while (tokenA.hasMoreTokens ()) {
00670                         try {
00671                                 this.parseAndLoadBlack ((tokenA.nextToken ()).trim ());
00672                         } catch (Exception e) {
00673                                 System.out.println ("loadBlack error");
00674                                 System.out.println (e);
00675                         }
00676                 }// end while
00677                 // this.printSBV();
00678                 SB [] sbArray = this.toSBArray ();
00679                 while (tokenB.hasMoreTokens ()) {
00680                         try {
00681                                 this.parseAndLoadGrey ((tokenB.nextToken ()).trim (), sbArray);
00682                         } catch (Exception e) {
00683                                 System.out.println ("load Grey error");
00684                                 System.out.println (e);
00685                         }
00686                 }// end while
00687                 this.traverseAndClose ();
00688         }
00689 
00690         public Vert traverseBlack (Vert last, SB current) {
00691                 try {
00692                         current.setVisited (true);
00693                         Vert next = current.getLeft ().getBlack ();
00694                         if (last == current.getLeft ()) {
00695                                 next = current.getRight ().getBlack ();
00696                                 buf.append (current.getValueA () + " ");
00697                         } else {
00698                                 buf.append ((current.getValueA () * -1) + " ");
00699                         }
00700                         if (!next.isCap () && !next.getSB ().wasVisited ()) {
00701                                 return traverseBlack (next, next.getSB ());
00702                         }
00703                         return next;
00704                 } catch (Exception e) {
00705                         return last;
00706                 }
00707         }
00708 
00709         public void resetSbVisit () {
00710                 SB tempSB;
00711                 for (Enumeration e = this.sbVector.elements (); e.hasMoreElements ();) {
00712                         tempSB = (SB) e.nextElement ();
00713                         tempSB.setVisited (false);
00714                 }
00715         }
00716 
00717         // prints state of SB vector
00718         public void printSBV () {
00719                 SB tempSB;
00720                 for (Enumeration e = this.sbVector.elements (); e.hasMoreElements ();) {
00721                         tempSB = (SB) e.nextElement ();
00722                         tempSB.getLeft ().printMe ();
00723                         tempSB.getRight ().printMe ();
00724 
00725                 }// end for
00726                 /***********************************************************************
00727                  * uncomment to print the caps** Vert tempCap; for(Enumeration
00728                  * e=this.capVector.elements();e.hasMoreElements();){
00729                  * tempCap=(Vert)e.nextElement(); tempCap.printMe(); }//end for
00730                  **********************************************************************/
00731         }
00732 
00733         // calls traverseBlack of class SB and prints the SB Values.
00734         // currently buggy
00735         public void printSBBlack () {
00736                 Vert v;
00737                 for (int i = 0; i < this.capVector.size (); i++) {
00738                         v = (Vert) this.capVector.elementAt (i);
00739                         if (!v.getBlack ().getSB ().wasVisited ()
00740                                         && !v.getBlack ().isCap ()) {
00741                                 buf.append ("[" + v.getGene () + " ");
00742                                 v = traverseBlack (v.getBlack (), v.getBlack ().getSB ());
00743                                 buf.append (v.getGene () + "]\n");
00744                         }
00745                 }
00746                 SB tempSB;
00747                 for (Enumeration e = this.sbVector.elements (); e.hasMoreElements ();) {
00748                         tempSB = (SB) e.nextElement ();
00749                         if (!tempSB.wasVisited ()) {
00750                                 buf.append ("[CI ");
00751                                 traverseBlack (tempSB.getLeft (), tempSB);
00752                                 buf.append ("]\n");
00753                         }
00754                 }
00755                 this.resetSbVisit ();
00756         }// end printSBBlack
00757 
00758 }// end class DCJ

Generated on Mon Aug 19 06:03:41 2013 for Mauve by doxygen 1.3.6