Debian Codegraph @

current/driver/Translator2.java

raw symbols SCIP
1 package driver;
2
3 import dna.Data;
4 import dna.Gene;
5 import fileIO.ChainLine;
6 import shared.Shared;
7
8 public class Translator2 {
9
10
11 public static void main(String[] args){
12
13 int from=Gene.toBuild(args[0]);
14 int to=Gene.toBuild(args[1]);
15
16 if(from==18){from=36;}
17 if(from==19){from=37;}
18 if(to==18){to=36;}
19 if(to==19){to=37;}
20 assert(from!=to);
21 assert(from==36 || from==37);
22 assert(to==36 || to==37);
23
24 int chrom=Gene.toChromosome(args[2]);
25
26 ChainLine[][] lines=Data.getChainLines(from, to);
27
28 for(int i=3; i<args.length; i++){
29 int loc=Integer.parseInt(args[i]);
30 int[] result=ChainLine.translate(loc, lines[chrom]);
31 System.out.print("(build"+from+", chr"+chrom+", +, "+loc+") -> ");
32 System.out.println(result==null ? "null" :
33 "(build"+to+", chr"+result[0]+", "+Shared.strandCodes[result[1]]+", "+result[2]+")");
34 }
35
36 // Translator2 tr=new Translator2(from, to);
37 //
38 // ChainLine[] array=lines[chrom];
39 // int index=ChainLine.binarySearch(loc, array);
40 //// if(index<0){return null;}
41 // ChainLine cl=array[index];
42 //
43 //// System.out.println(cl);
44 //
45 // int[] dest=cl.translate(loc);
46 //
47 //// {qChrom, qStrand, qStart+loc-tStart};
48 //
49 // System.out.println(chrom+", +, "+loc+" -> "+dest[0]+", "+Gene.strandCodes[dest[1]]+", "+dest[2]);
50 }
51
52 /** chrom, strand, loc */
53 public static final int[] translate(int fromBuild, int toBuild, int chrom, int strand, int loc){
54 ChainLine[][] lines=Data.getChainLines(fromBuild, toBuild);
55 int[] result=ChainLine.translate(loc, lines[chrom]);
56 if(result==null){return null;}
57 int strand2=result[1];
58 if(strand2==strand){
59 result[1]=Shared.PLUS;
60 }else{
61 result[1]=Shared.MINUS;
62 }
63 return result;
64 }
65
66 }