String seqstring, int[] viscontigs, AlignedCodonFrame codons,\r
char gapCharacter, DBRefEntry product)\r
{\r
+ Vector skip=new Vector();\r
+ int skipint[]=null;\r
ShiftList vismapping = new ShiftList(); // map from viscontigs to seqstring\r
// intervals\r
int vc, scontigs[] = new int[viscontigs.length];\r
int npos = 0;\r
for (vc = 0; vc < viscontigs.length; vc += 2)\r
{\r
+ if (vc==0) {\r
vismapping.addShift(npos, viscontigs[vc]);\r
- scontigs[vc] = npos;\r
- npos += viscontigs[vc + 1];\r
- scontigs[vc + 1] = npos;\r
+ } else {\r
+ // hidden region\r
+ vismapping.addShift(npos, viscontigs[vc]-viscontigs[vc-1]+1);\r
+ }\r
+ scontigs[vc] = viscontigs[vc];\r
+ scontigs[vc + 1] = viscontigs[vc+1];\r
}\r
\r
StringBuffer protein = new StringBuffer();\r
String aa = ResidueProperties.codonTranslate(new String(codon));\r
rf = 0;\r
if (aa == null)\r
- aa = String.valueOf(gapCharacter);\r
- else\r
{\r
+ aa = String.valueOf(gapCharacter);\r
+ if (skipint==null)\r
+ {\r
+ skipint = new int[] { cdp[0],cdp[2] };\r
+ }\r
+ skipint[1] = cdp[2];\r
+ } else {\r
+ if (skipint!=null)\r
+ {\r
+ // edit scontigs\r
+ skipint[0] = vismapping.shift(skipint[0]);\r
+ skipint[1] = vismapping.shift(skipint[1]);\r
+ for (vc=0; vc<scontigs.length; vc+=2)\r
+ {\r
+ if (scontigs[vc+1]<skipint[0])\r
+ {\r
+ continue;\r
+ }\r
+ if (scontigs[vc]<=skipint[0])\r
+ {\r
+ if (skipint[0]==scontigs[vc])\r
+ {\r
+ \r
+ } else {\r
+ int[] t = new int[scontigs.length+2];\r
+ System.arraycopy(scontigs, 0, t, 0, vc-1);\r
+ // scontigs[vc]; //\r
+ }\r
+ }\r
+ }\r
+ skip.addElement(skipint);\r
+ skipint=null;\r
+ }\r
if (aa.equals("STOP"))\r
{\r
aa = "X";\r
}\r
aspos++;\r
if (aspos >= codons.aaWidth)\r
+ {\r
codons.aaWidth = aspos + 1;\r
+ }\r
}\r
}\r
if (resSize > 0)\r
if (scontigs != null)\r
{\r
npos = 0;\r
- // Find sequence position for scontigs positions on the nucleotide\r
- // sequence string we were passed.\r
- for (vc = 0; vc < viscontigs.length; vc += 2)\r
+ // map scontigs to actual sequence positions on selection\r
+ for (vc = 0; vc < scontigs.length; vc += 2)\r
{\r
scontigs[vc] = selection.findPosition(scontigs[vc]); // not from 1!\r
- npos += viscontigs[vc];\r
scontigs[vc + 1] = selection\r
- .findPosition(npos + scontigs[vc + 1]); // exclusive\r
+ .findPosition(scontigs[vc + 1]); // exclusive\r
if (scontigs[vc + 1] == selection.getEnd())\r
break;\r
}\r
System.arraycopy(scontigs, 0, t, 0, vc + 2);\r
scontigs = t;\r
}\r
+ /*\r
+ * delete intervals in scontigs which are not translated.\r
+ * 1. map skip into sequence position intervals\r
+ * 2. truncate existing ranges and add new ranges to exclude untranslated regions.\r
+ if (skip.size()>0)\r
+ {\r
+ Vector narange = new Vector();\r
+ for (vc=0; vc<scontigs.length; vc++)\r
+ {\r
+ narange.addElement(new int[] {scontigs[vc]});\r
+ }\r
+ int sint=0,iv[];\r
+ vc = 0;\r
+ while (sint<skip.size())\r
+ {\r
+ skipint = (int[]) skip.elementAt(sint);\r
+ do {\r
+ iv = (int[]) narange.elementAt(vc);\r
+ if (iv[0]>=skipint[0] && iv[0]<=skipint[1])\r
+ {\r
+ if (iv[0]==skipint[0])\r
+ {\r
+ // delete beginning of range\r
+ } else {\r
+ // truncate range and create new one if necessary\r
+ iv = (int[]) narange.elementAt(vc+1);\r
+ if (iv[0]<=skipint[1])\r
+ {\r
+ // truncate range\r
+ iv[0] = skipint[1];\r
+ } else {\r
+ \r
+ }\r
+ }\r
+ } else\r
+ if (iv[0]<skipint[0])\r
+ {\r
+ iv = (int[]) narange.elementAt(vc+1);\r
+ }\r
+ } while (iv[0])\r
+ }\r
+ }*/\r
MapList map = new MapList(scontigs, new int[]\r
{ 1, resSize }, 3, 1);\r
+ \r
// update newseq as if it was generated as mapping from product\r
\r
if (product != null)\r