src/org/gel/mauve/Match.java

Go to the documentation of this file.
00001 package org.gel.mauve;
00002 
00003 import java.awt.Color;
00004 import java.io.Serializable;
00005 
00006 import org.gel.mauve.analysis.Segment;
00007 
00013 public class Match extends Segment //implements Serializable
00014 {
00015         static final long serialVersionUID = 1;
00016     public static final int NO_MATCH = 0;
00017     // The color code of this match
00018     public Color color;
00019     // true if the match is highlighted on screen
00020     public boolean highlighted = false;
00021     // The lcb which this match belongs to
00022     public int lcb = 0;
00023 
00024     // The start coordinate of this match in each sequence
00025     //private long[] starts;
00026     // The lengths of this match in each sequence
00027     //private long[] ends;
00028     // The direction of each match. false is forward, true is reverse
00029     //private boolean[] reverse;
00030 
00031     public Match(int sequenceCount)
00032     {
00033         left = new long[sequenceCount];
00034         right = new long[sequenceCount];
00035         reverse = new boolean[sequenceCount];
00036     }
00037 
00038     public Match(Match m)
00039     {
00040         left = new long[m.left.length];
00041         right = new long[m.right.length];
00042         reverse = new boolean[m.reverse.length];
00043         System.arraycopy(m.left, 0, left, 0, left.length);
00044         System.arraycopy(m.right, 0, right, 0, right.length);
00045         System.arraycopy(m.reverse, 0, reverse, 0, reverse.length);
00046 
00047         color = m.color;
00048         lcb = m.lcb;
00049     }
00050 
00051     public long getStart(Genome g)
00052     {
00053         return left[g.getSourceIndex()]; 
00054     }
00055     
00061     public long getStart(int sourceIndex)
00062     {
00063         return left[sourceIndex];
00064     }
00065     
00066     public void setStart(Genome g, long start)
00067     {
00068         left[g.getSourceIndex()] = start;
00069     }
00070     public void setStart(int sourceIndex, long start)
00076     {
00077         left[sourceIndex] = start;
00078     }
00079     
00080     public long getLength(Genome g)
00081     {
00082         return right[g.getSourceIndex()];
00083     }
00084     
00090     public long getLength(int sourceIndex)
00091     {
00092         return right[sourceIndex];
00093     }
00094     
00095     public void setLength(Genome g, long length)
00096     {
00097         right[g.getSourceIndex()] = length;
00098     }
00099     
00105     public void setLength(int sourceIndex, long length)
00106     {
00107         right[sourceIndex] = length;
00108     }
00109     
00110     public boolean getReverse(Genome g)
00111     {
00112         return reverse[g.getSourceIndex()];
00113     }
00114     
00115 public boolean getReverse(int sourceIndex)
00121     {
00122         return reverse[sourceIndex];
00123     }
00124     
00125     public void setReverse(Genome g, boolean r)
00126     {
00127         reverse[g.getSourceIndex()] = r;
00128     }
00129     
00135     public void setReverse(int sourceIndex, boolean r)
00136     {
00137         reverse[sourceIndex] = r;
00138     }
00139     
00141     public long offset()
00142     {
00143         int seqI = 0;
00144         long ref;
00145         long g_offset = 0;
00146         for (; seqI < left.length; seqI++)
00147         {
00148             if (left[seqI] != NO_MATCH)
00149                 break;
00150         }
00151         ref = left[seqI];
00152         for (; seqI < left.length; seqI++)
00153         {
00154             long cur_start = left[seqI];
00155             if (reverse[seqI])
00156                 cur_start = -cur_start;
00157             g_offset += ref - cur_start;
00158         }
00159 
00160         return g_offset;
00161     }
00162 
00163     public void copyArrays(LCB lcb, long[] starts, long[] lengths, boolean[] reverse, int seq_count)
00164     {
00165         System.arraycopy(this.left, 0, starts, 0, seq_count);
00166         System.arraycopy(this.right, 0, lengths, 0, seq_count);
00167         System.arraycopy(this.reverse, 0, reverse, 0, seq_count);
00168     }
00169 
00170 }

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