/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
*/
package jalview.ws.jws1;
-import java.util.*;
-
-import jalview.analysis.*;
-import jalview.bin.*;
-import jalview.datamodel.*;
-import jalview.gui.*;
-import jalview.io.*;
-import jalview.util.*;
+import jalview.analysis.AlignSeq;
+import jalview.analysis.SeqsetUtils;
+import jalview.bin.Cache;
+import jalview.commands.RemoveGapsCommand;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.AlignmentView;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
+import jalview.gui.WebserviceInfo;
+import jalview.io.FormatAdapter;
+import jalview.io.IdentifyFile;
+import jalview.io.JPredFile;
+import jalview.io.JnetAnnotationMaker;
+import jalview.io.PileUpfile;
+import jalview.util.Comparison;
+import jalview.util.MessageManager;
import jalview.ws.AWsJob;
import jalview.ws.JobStateSummary;
import jalview.ws.WSClientI;
+
+import java.util.Hashtable;
+import java.util.List;
+
import vamsas.objects.simple.JpredResult;
+import vamsas.objects.simple.Msfalignment;
class JPredThread extends JWS1Thread implements WSClientI
{
{
return null;
}
- Alignment al = null;
+ AlignmentI al = null;
ColumnSelection alcsel = null;
int FirstSeq = -1; // the position of the query sequence in Alignment al
JpredResult result = (JpredResult) this.result;
- jalview.bin.Cache.log.debug("Parsing output from JNet job.");
+ Cache.log.debug("Parsing output from JNet job.");
// JPredFile prediction = new JPredFile("C:/JalviewX/files/jpred.txt",
// "File");
- jalview.io.JPredFile prediction = new jalview.io.JPredFile(
- result.getPredfile(), "Paste");
+ JPredFile prediction = new JPredFile(result.getPredfile(), "Paste");
SequenceI[] preds = prediction.getSeqsAsArray();
- jalview.bin.Cache.log.debug("Got prediction profile.");
+ Cache.log.debug("Got prediction profile.");
if ((this.msa != null) && (result.getAligfile() != null))
{
- jalview.bin.Cache.log.debug("Getting associated alignment.");
+ Cache.log.debug("Getting associated alignment.");
// we ignore the returned alignment if we only predicted on a single
// sequence
- String format = new jalview.io.IdentifyFile().Identify(
- result.getAligfile(), "Paste");
+ String format = new IdentifyFile().Identify(result.getAligfile(),
+ "Paste");
- if (jalview.io.FormatAdapter.isValidFormat(format))
+ if (FormatAdapter.isValidFormat(format))
{
SequenceI sqs[];
if (predMap != null)
{
sqs[i] = al.getSequenceAt(i);
}
- if (!jalview.analysis.SeqsetUtils.deuniquify(
- (Hashtable) SequenceInfo, sqs))
+ if (!SeqsetUtils.deuniquify(SequenceInfo, sqs))
{
throw (new Exception(MessageManager.getString("exception.couldnt_recover_sequence_properties_for_alignment")));
}
}
FirstSeq = 0;
- al.setDataset(null);
+ if (currentView.getDataset() != null)
+ {
+ al.setDataset(currentView.getDataset());
- jalview.io.JnetAnnotationMaker.add_annotation(prediction, al,
- FirstSeq, false, predMap);
+ }
+ else
+ {
+ al.setDataset(null);
+ }
+ JnetAnnotationMaker.add_annotation(prediction, al, FirstSeq,
+ false, predMap);
}
else
if (predMap != null)
{
char gc = getGapChar();
- SequenceI[] sqs = (SequenceI[]) ((java.lang.Object[]) input
- .getAlignmentAndColumnSelection(gc))[0];
+ SequenceI[] sqs = (SequenceI[]) input
+ .getAlignmentAndColumnSelection(gc)[0];
if (this.msaIndex >= sqs.length)
{
throw new Error(MessageManager.getString("error.implementation_error_invalid_msa_index_for_job"));
// ///
// Uses RemoveGapsCommand
// ///
- new jalview.commands.RemoveGapsCommand(MessageManager.getString("label.remove_gaps"),
+ new RemoveGapsCommand(
+ MessageManager.getString("label.remove_gaps"),
new SequenceI[]
{ sqs[msaIndex] }, currentView);
profileseq.setSequence(sqs[msaIndex].getSequenceAsString());
}
- if (!jalview.analysis.SeqsetUtils.SeqCharacterUnhash(
+ if (!SeqsetUtils.SeqCharacterUnhash(
al.getSequenceAt(FirstSeq), SequenceInfo))
{
throw (new Exception(MessageManager.getString("exception.couldnt_recover_sequence_props_for_jnet_query")));
}
else
{
- al.setDataset(null);
- jalview.io.JnetAnnotationMaker.add_annotation(prediction, al,
+ if (currentView.getDataset() != null)
+ {
+ al.setDataset(currentView.getDataset());
+
+ }
+ else
+ {
+ al.setDataset(null);
+ }
+ JnetAnnotationMaker.add_annotation(prediction, al,
FirstSeq, true, predMap);
SequenceI profileseq = al.getSequenceAt(0); // this includes any gaps.
alignToProfileSeq(al, profileseq);
}
}
}
+ // transfer to dataset
+ for (AlignmentAnnotation alant : al.getAlignmentAnnotation())
+ {
+ if (alant.sequenceRef != null)
+ {
+ replaceAnnotationOnAlignmentWith(alant, alant.label,
+ "jalview.jws1.Jpred" + (this.msa == null ? "" : "MSA"),
+ alant.sequenceRef);
+ }
+ }
return new Object[]
{ al, alcsel }; // , FirstSeq, noMsa};
}
/**
+ * copied from JabawsCalcWorker
+ *
+ * @param newAnnot
+ * @param typeName
+ * @param calcId
+ * @param aSeq
+ */
+ protected void replaceAnnotationOnAlignmentWith(
+ AlignmentAnnotation newAnnot, String typeName, String calcId,
+ SequenceI aSeq)
+ {
+ SequenceI dsseq = aSeq.getDatasetSequence();
+ while (dsseq.getDatasetSequence() != null)
+ {
+ dsseq = dsseq.getDatasetSequence();
+ }
+ // look for same annotation on dataset and lift this one over
+ List<AlignmentAnnotation> dsan = dsseq.getAlignmentAnnotations(
+ calcId, typeName);
+ if (dsan != null && dsan.size() > 0)
+ {
+ for (AlignmentAnnotation dssan : dsan)
+ {
+ dsseq.removeAlignmentAnnotation(dssan);
+ }
+ }
+ AlignmentAnnotation dssan = new AlignmentAnnotation(newAnnot);
+ dsseq.addAlignmentAnnotation(dssan);
+ dssan.adjustForAlignment();
+ }
+
+ /**
* Given an alignment where all other sequences except profileseq are
* aligned to the ungapped profileseq, insert gaps in the other sequences to
* realign them with the residues in profileseq
* @param al
* @param profileseq
*/
- private void alignToProfileSeq(Alignment al, SequenceI profileseq)
+ private void alignToProfileSeq(AlignmentI al, SequenceI profileseq)
{
char gc = al.getGapCharacter();
int[] gapMap = profileseq.gapMap();
{
if (msf.length > 1)
{
- msa = new vamsas.objects.simple.Msfalignment();
- jalview.io.PileUpfile pileup = new jalview.io.PileUpfile();
+ msa = new Msfalignment();
+ PileUpfile pileup = new PileUpfile();
msa.setMsf(pileup.print(msf));
}
}
{
if (job.getJobId().startsWith("Broken"))
{
- job.result = (vamsas.objects.simple.Result) new JpredResult();
+ job.result = new JpredResult();
job.result.setInvalid(true);
job.result.setStatus(MessageManager.formatMessage("label.submission_params", new String[]{job.getJobId().toString()}));
throw new Exception(job.getJobId());
.println("JPredWS Client: Failed to submit the prediction. Quite possibly because of a server error - see below)\n"
+ e.getMessage() + "\n");
- jalview.bin.Cache.log.warn("Server Exception", e);
+ Cache.log.warn("Server Exception", e);
}
else
{
// JBPNote - this could be a popup informing the user of the problem.
wsInfo.appendProgressText(j.getJobnum(), MessageManager.formatMessage("info.failed_to_submit_prediction", new String[]{e.getMessage(),wsInfo.getProgressText()}));
- jalview.bin.Cache.log.debug(
+ Cache.log.debug(
"Failed Submission of job " + j.getJobnum(), e);
}
msa = (j.msa != null) ? true : msa;
try
{
- jalview.bin.Cache.log.debug("Parsing output of job " + jn);
+ Cache.log.debug("Parsing output of job " + jn);
jobres = j.getResultSet();
- jalview.bin.Cache.log.debug("Finished parsing output.");
+ Cache.log.debug("Finished parsing output.");
if (jobs.length == 1)
{
res = jobres;
}
} catch (Exception e)
{
- jalview.bin.Cache.log.error(
+ Cache.log.error(
"JNet Client: JPred Annotation Parse Error", e);
wsInfo.setStatus(j.getJobnum(),
WebserviceInfo.STATE_STOPPED_ERROR);