X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fjalview%2Fio%2FJnetAnnotationMaker.js;h=e2f51a55524112f56bca41b6424b865f6d3c9bb5;hp=f39d55b539dc090ac7c877488fdb00ec4d66ec44;hb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/jalview/io/JnetAnnotationMaker.js b/bin/jalview/io/JnetAnnotationMaker.js index f39d55b..e2f51a5 100644 --- a/bin/jalview/io/JnetAnnotationMaker.js +++ b/bin/jalview/io/JnetAnnotationMaker.js @@ -1,90 +1,90 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (null, "jalview.io.JnetAnnotationMaker", ["jalview.datamodel.AlignmentAnnotation", "$.Annotation", "jalview.util.MessageManager", "java.lang.Exception", "$.Float"], function () { -c$ = Clazz.declareType (jalview.io, "JnetAnnotationMaker"); -c$.add_annotation = Clazz.defineMethod (c$, "add_annotation", -function (prediction, al, firstSeq, noMsa) { -jalview.io.JnetAnnotationMaker.add_annotation (prediction, al, firstSeq, noMsa, Clazz.castNullAs ("Array")); -}, "jalview.io.AlignFile,jalview.datamodel.AlignmentI,~N,~B"); -c$.add_annotation = Clazz.defineMethod (c$, "add_annotation", -function (prediction, al, firstSeq, noMsa, delMap) { -var i = 0; -var preds = prediction.getSeqsAsArray (); -var seqRef = al.getSequenceAt (firstSeq); -var width = preds[0].getSequence ().length; -var gapmap = al.getSequenceAt (firstSeq).gapMap (); -if ((delMap != null && delMap.length > width) || (delMap == null && gapmap.length != width)) { -throw ( new Exception (jalview.util.MessageManager.formatMessage ("exception.number_of_residues_in_query_sequence_differ_from_prediction", Clazz.newArray (-1, [(delMap == null ? "" : jalview.util.MessageManager.getString ("label.mapped")), al.getSequenceAt (firstSeq).getName (), al.getSequenceAt (firstSeq).getSequenceAsString (), Integer.$valueOf (width).toString ()])))); -}var annot; -var annotations = null; -var existingAnnotations = 0; -if (al.getAlignmentAnnotation () != null) { -existingAnnotations = al.getAlignmentAnnotation ().length; -}var sol = new Array (al.getWidth ()); -var firstsol = true; -while (i < preds.length) { -var id = preds[i].getName ().toUpperCase (); -if (id.startsWith ("LUPAS") || id.startsWith ("JNET") || id.startsWith ("JPRED")) { -if (id.startsWith ("JNETSOL")) { -var amnt = (id.endsWith ("25") ? 3 : id.endsWith ("5") ? 6 : 9); -for (var spos = 0; spos < width; spos++) { -var sposw = (delMap == null) ? gapmap[spos] : gapmap[delMap[spos]]; -if (firstsol) { -sol[sposw] = new jalview.datamodel.Annotation (0); -}if (preds[i].getCharAt (spos) == 'B' && (sol[sposw].value == 0 || sol[sposw].value < amnt)) { -sol[sposw].value = amnt; -}} -firstsol = false; -} else { -annotations = new Array (al.getWidth ()); -if (id.equals ("JNETPRED") || id.equals ("JNETPSSM") || id.equals ("JNETFREQ") || id.equals ("JNETHMM") || id.equals ("JNETALIGN") || id.equals ("JPRED")) { -if (delMap == null) { -for (var j = 0; j < width; j++) { -annotations[gapmap[j]] = new jalview.datamodel.Annotation ("", "", preds[i].getCharAt (j), 0); -} -} else { -for (var j = 0; j < width; j++) { -annotations[gapmap[delMap[j]]] = new jalview.datamodel.Annotation ("", "", preds[i].getCharAt (j), 0); -} -}} else if (id.equals ("JNETCONF")) { -if (delMap == null) { -for (var j = 0; j < width; j++) { -var value = new Float (preds[i].getCharAt (j) + "").floatValue (); -annotations[gapmap[j]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", preds[i].getCharAt (j), value); -} -} else { -for (var j = 0; j < width; j++) { -var value = new Float (preds[i].getCharAt (j) + "").floatValue (); -annotations[gapmap[delMap[j]]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", preds[i].getCharAt (j), value); -} -}} else { -if (delMap == null) { -for (var j = 0; j < width; j++) { -annotations[gapmap[j]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", ' ', 0); -} -} else { -for (var j = 0; j < width; j++) { -annotations[gapmap[delMap[j]]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", ' ', 0); -} -}}if (id.equals ("JNETCONF")) { -annot = new jalview.datamodel.AlignmentAnnotation (preds[i].getName (), "JNet Output", annotations, 0, 10, 1); -} else { -annot = new jalview.datamodel.AlignmentAnnotation (preds[i].getName (), "JNet Output", annotations); -}if (seqRef != null) { -annot.createSequenceMapping (seqRef, 1, true); -seqRef.addAlignmentAnnotation (annot); -}al.addAnnotation (annot); -al.setAnnotationIndex (annot, al.getAlignmentAnnotation ().length - existingAnnotations - 1); -}if (noMsa) { -al.deleteSequence (preds[i]); -}}i++; -} -if (!firstsol) { -annot = new jalview.datamodel.AlignmentAnnotation ("Jnet Burial", "Prediction of Solvent Accessibility
levels are", sol, 0, 9, 1); -annot.validateRangeAndDisplay (); -if (seqRef != null) { -annot.createSequenceMapping (seqRef, 1, true); -seqRef.addAlignmentAnnotation (annot); -}al.addAnnotation (annot); -al.setAnnotationIndex (annot, al.getAlignmentAnnotation ().length - existingAnnotations - 1); -}}, "jalview.io.AlignFile,jalview.datamodel.AlignmentI,~N,~B,~A"); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (null, "jalview.io.JnetAnnotationMaker", ["jalview.datamodel.AlignmentAnnotation", "$.Annotation", "jalview.util.MessageManager", "java.lang.Exception", "$.Float"], function () { +c$ = Clazz.declareType (jalview.io, "JnetAnnotationMaker"); +c$.add_annotation = Clazz.defineMethod (c$, "add_annotation", +function (prediction, al, firstSeq, noMsa) { +jalview.io.JnetAnnotationMaker.add_annotation (prediction, al, firstSeq, noMsa, Clazz.castNullAs ("Array")); +}, "jalview.io.AlignFile,jalview.datamodel.AlignmentI,~N,~B"); +c$.add_annotation = Clazz.defineMethod (c$, "add_annotation", +function (prediction, al, firstSeq, noMsa, delMap) { +var i = 0; +var preds = prediction.getSeqsAsArray (); +var seqRef = al.getSequenceAt (firstSeq); +var width = preds[0].getSequence ().length; +var gapmap = al.getSequenceAt (firstSeq).gapMap (); +if ((delMap != null && delMap.length > width) || (delMap == null && gapmap.length != width)) { +throw ( new Exception (jalview.util.MessageManager.formatMessage ("exception.number_of_residues_in_query_sequence_differ_from_prediction", Clazz.newArray (-1, [(delMap == null ? "" : jalview.util.MessageManager.getString ("label.mapped")), al.getSequenceAt (firstSeq).getName (), al.getSequenceAt (firstSeq).getSequenceAsString (), Integer.$valueOf (width).toString ()])))); +}var annot; +var annotations = null; +var existingAnnotations = 0; +if (al.getAlignmentAnnotation () != null) { +existingAnnotations = al.getAlignmentAnnotation ().length; +}var sol = new Array (al.getWidth ()); +var firstsol = true; +while (i < preds.length) { +var id = preds[i].getName ().toUpperCase (); +if (id.startsWith ("LUPAS") || id.startsWith ("JNET") || id.startsWith ("JPRED")) { +if (id.startsWith ("JNETSOL")) { +var amnt = (id.endsWith ("25") ? 3 : id.endsWith ("5") ? 6 : 9); +for (var spos = 0; spos < width; spos++) { +var sposw = (delMap == null) ? gapmap[spos] : gapmap[delMap[spos]]; +if (firstsol) { +sol[sposw] = new jalview.datamodel.Annotation (0); +}if (preds[i].getCharAt (spos) == 'B' && (sol[sposw].value == 0 || sol[sposw].value < amnt)) { +sol[sposw].value = amnt; +}} +firstsol = false; +} else { +annotations = new Array (al.getWidth ()); +if (id.equals ("JNETPRED") || id.equals ("JNETPSSM") || id.equals ("JNETFREQ") || id.equals ("JNETHMM") || id.equals ("JNETALIGN") || id.equals ("JPRED")) { +if (delMap == null) { +for (var j = 0; j < width; j++) { +annotations[gapmap[j]] = new jalview.datamodel.Annotation ("", "", preds[i].getCharAt (j), 0); +} +} else { +for (var j = 0; j < width; j++) { +annotations[gapmap[delMap[j]]] = new jalview.datamodel.Annotation ("", "", preds[i].getCharAt (j), 0); +} +}} else if (id.equals ("JNETCONF")) { +if (delMap == null) { +for (var j = 0; j < width; j++) { +var value = new Float (preds[i].getCharAt (j) + "").floatValue (); +annotations[gapmap[j]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", preds[i].getCharAt (j), value); +} +} else { +for (var j = 0; j < width; j++) { +var value = new Float (preds[i].getCharAt (j) + "").floatValue (); +annotations[gapmap[delMap[j]]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", preds[i].getCharAt (j), value); +} +}} else { +if (delMap == null) { +for (var j = 0; j < width; j++) { +annotations[gapmap[j]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", ' ', 0); +} +} else { +for (var j = 0; j < width; j++) { +annotations[gapmap[delMap[j]]] = new jalview.datamodel.Annotation (preds[i].getCharAt (j) + "", "", ' ', 0); +} +}}if (id.equals ("JNETCONF")) { +annot = new jalview.datamodel.AlignmentAnnotation (preds[i].getName (), "JNet Output", annotations, 0, 10, 1); +} else { +annot = new jalview.datamodel.AlignmentAnnotation (preds[i].getName (), "JNet Output", annotations); +}if (seqRef != null) { +annot.createSequenceMapping (seqRef, 1, true); +seqRef.addAlignmentAnnotation (annot); +}al.addAnnotation (annot); +al.setAnnotationIndex (annot, al.getAlignmentAnnotation ().length - existingAnnotations - 1); +}if (noMsa) { +al.deleteSequence (preds[i]); +}}i++; +} +if (!firstsol) { +annot = new jalview.datamodel.AlignmentAnnotation ("Jnet Burial", "Prediction of Solvent Accessibility
levels are", sol, 0, 9, 1); +annot.validateRangeAndDisplay (); +if (seqRef != null) { +annot.createSequenceMapping (seqRef, 1, true); +seqRef.addAlignmentAnnotation (annot); +}al.addAnnotation (annot); +al.setAnnotationIndex (annot, al.getAlignmentAnnotation ().length - existingAnnotations - 1); +}}, "jalview.io.AlignFile,jalview.datamodel.AlignmentI,~N,~B,~A"); +});