Debian Codegraph @

current/assemble/Edge.java

raw symbols SCIP
1 package assemble;
2
3 import dna.AminoAcid;
4 import structures.ByteBuilder;
5
6 public class Edge {
7
8 public Edge(int origin_, int destination_, int length_, int orientation_, int depth_, byte[] bases_){
9 origin=origin_;
10 destination=destination_;
11 length=length_;
12 orientation=orientation_;
13 depth=depth_;
14 bases=bases_;
15 }
16
17 @Override
18 public String toString(){
19 return appendTo(new ByteBuilder()).toString();
20 }
21
22 public ByteBuilder appendTo(ByteBuilder bb){
23 bb.append('(');
24 bb.append(destination).append('-')/*.append(direction).append('-')*/.append(orientation);
25 bb.append('-').append(length).append('-').append(depth).append('-').append(bases);
26 bb.append(')');
27 return bb;
28 }
29
30 public void toDot(ByteBuilder bb){
31 bb.append(origin);
32 bb.append(" -> ");
33 bb.append(destination);
34 bb.append(" [label=\"").append(((orientation&1)==0) ? "LEFT" : "RIGHT").append("\\nlen=").append(length);
35 bb.append("\\norient=").append(orientation).append("\"]").append('\n');
36 }
37
38 public boolean destRight() {
39 return (orientation&2)==2;
40 }
41 public boolean sourceRight() {
42 return (orientation&1)==1;
43 }
44
45 void flipSource(){
46 if(Tadpole.verbose){System.err.print("Flipping edge source "+this+" -> ");}
47 if(bases!=null){AminoAcid.reverseComplementBasesInPlace(bases);}
48 orientation^=1;
49 if(Tadpole.verbose){System.err.println(this);}
50 }
51
52 void flipDest(){
53 if(Tadpole.verbose){System.err.print("Flipping edge dest "+this+" -> ");}
54 orientation^=2;
55 if(Tadpole.verbose){System.err.println(this);}
56 }
57
58 void merge(Edge e){
59 assert(e.origin==origin);
60 assert(e.destination==destination);
61 assert(e.orientation==orientation);
62 if(e.depth>depth){
63 length=e.length;
64 bases=e.bases;
65 orientation=e.orientation;
66 depth+=e.depth;
67 }else{
68 depth+=e.depth;
69 }
70 }
71
72 byte[] bases;
73 int origin;
74 int destination;
75 int length;
76 int orientation; //left source to left dest; 1 right source to left dest; 2 left source to right dest; 3 right source to right dest
77 // int orientation; //0 left kmer, 1 left rkmer, 2 right kmer, 3 right rkmer (of dest)
78 // final int direction; //0 forward, 1 backward //They are all forward edges now
79 int depth;
80
81 }