|
| 1 | +package objects.CoordinateObjects; |
| 2 | + |
| 3 | +import java.util.Comparator; |
| 4 | + |
| 5 | +public class GenericCoord implements GenomicCoord { |
| 6 | + private String CHROM = ""; |
| 7 | + private int START = 0; |
| 8 | + private int STOP = 0; |
| 9 | + private String DIR = "+"; |
| 10 | + |
| 11 | + private String NAME = "."; |
| 12 | + private double SCORE = 0; |
| 13 | + |
| 14 | + public GenericCoord() { |
| 15 | + |
| 16 | + } |
| 17 | + |
| 18 | + public GenericCoord(String c, long sta, long sto, String di) { |
| 19 | + CHROM = c; |
| 20 | + START = (int)sta; |
| 21 | + STOP = (int)sto; |
| 22 | + DIR = di; |
| 23 | + NAME = CHROM + "_" + START + "_" + STOP + "_" + DIR; |
| 24 | + } |
| 25 | + |
| 26 | + public GenericCoord(String c, int sta, int sto, String di, String na) { |
| 27 | + CHROM = c; |
| 28 | + START = sta; |
| 29 | + STOP = sto; |
| 30 | + DIR = di; |
| 31 | + NAME = na; |
| 32 | + } |
| 33 | + |
| 34 | + public String getChrom() { |
| 35 | + return CHROM; |
| 36 | + } |
| 37 | + |
| 38 | + public void setChrom(String chr) { |
| 39 | + CHROM = chr; |
| 40 | + } |
| 41 | + |
| 42 | + public int getStart() { |
| 43 | + return START; |
| 44 | + } |
| 45 | + |
| 46 | + public void setStart(int sta) { |
| 47 | + START = sta; |
| 48 | + } |
| 49 | + |
| 50 | + public int getStop() { |
| 51 | + return STOP; |
| 52 | + } |
| 53 | + |
| 54 | + public void setStop(int sto) { |
| 55 | + STOP = sto; |
| 56 | + } |
| 57 | + |
| 58 | + public String getDir() { |
| 59 | + return DIR; |
| 60 | + } |
| 61 | + |
| 62 | + public void setDir(String di) { |
| 63 | + DIR = di; |
| 64 | + } |
| 65 | + |
| 66 | + public String getName() { |
| 67 | + return NAME; |
| 68 | + } |
| 69 | + |
| 70 | + public void setName(String na) { |
| 71 | + NAME = na; |
| 72 | + } |
| 73 | + |
| 74 | + public double getScore() { |
| 75 | + return SCORE; |
| 76 | + } |
| 77 | + |
| 78 | + public void setScore(double sco) { |
| 79 | + SCORE = sco; |
| 80 | + } |
| 81 | + |
| 82 | + public String toString() { |
| 83 | + String line = CHROM + "\t" + START + "\t" + STOP + "\t" + NAME + "\t" + SCORE + "\t" + DIR; |
| 84 | + return line; |
| 85 | + } |
| 86 | + |
| 87 | + public static Comparator<GenericCoord> PeakChromComparator = new Comparator<GenericCoord>() { |
| 88 | + public int compare(GenericCoord node1, GenericCoord node2) { |
| 89 | + return node1.getChrom().compareTo(node2.getChrom()); |
| 90 | + } |
| 91 | + }; |
| 92 | + |
| 93 | + public static Comparator<GenericCoord> PeakPositionComparator = new Comparator<GenericCoord>() { |
| 94 | + public int compare(GenericCoord node1, GenericCoord node2) { |
| 95 | + int PeakStart1 = node1.getStart(); |
| 96 | + int PeakStart2 = node2.getStart(); |
| 97 | + if (PeakStart1 > PeakStart2) return 1; |
| 98 | + else if (PeakStart1 < PeakStart2) return -1; |
| 99 | + else return 0; |
| 100 | + } |
| 101 | + }; |
| 102 | + |
| 103 | + public static Comparator<GenericCoord> ScoreComparator = new Comparator<GenericCoord>() { |
| 104 | + public int compare(GenericCoord node1, GenericCoord node2) { |
| 105 | + double PeakStart1 = node1.getScore(); |
| 106 | + double PeakStart2 = node2.getScore(); |
| 107 | + if (PeakStart1 < PeakStart2) return 1; |
| 108 | + else if (PeakStart1 > PeakStart2) return -1; |
| 109 | + else return 0; |
| 110 | + } |
| 111 | + }; |
| 112 | +} |
0 commit comments