| 1 |
|
package jalview.ws.jws2.jabaws2; |
| 2 |
|
|
| 3 |
|
import jalview.datamodel.AlignmentI; |
| 4 |
|
import jalview.datamodel.Sequence; |
| 5 |
|
import jalview.datamodel.SequenceI; |
| 6 |
|
import jalview.ws.api.CancellableI; |
| 7 |
|
import jalview.ws.api.JobId; |
| 8 |
|
import jalview.ws.api.MultipleSequenceAlignmentI; |
| 9 |
|
import jalview.ws.jws2.JabaParamStore; |
| 10 |
|
import jalview.ws.jws2.JabaPreset; |
| 11 |
|
import jalview.ws.params.ArgumentI; |
| 12 |
|
import jalview.ws.params.InvalidArgumentException; |
| 13 |
|
import jalview.ws.params.WsParamSetI; |
| 14 |
|
|
| 15 |
|
import java.io.IOError; |
| 16 |
|
import java.rmi.ServerError; |
| 17 |
|
import java.util.ArrayList; |
| 18 |
|
import java.util.List; |
| 19 |
|
|
| 20 |
|
import compbio.data.sequence.Alignment; |
| 21 |
|
import compbio.data.sequence.FastaSequence; |
| 22 |
|
import compbio.metadata.ResultNotAvailableException; |
| 23 |
|
|
| |
|
| 0% |
Uncovered Elements: 41 (41) |
Complexity: 10 |
Complexity Density: 0.36 |
|
| 24 |
|
public class JabawsMsaInstance |
| 25 |
|
extends JabawsServiceInstance<compbio.data.msa.MsaWS> |
| 26 |
|
implements MultipleSequenceAlignmentI, CancellableI |
| 27 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 6 |
Complexity Density: 0.43 |
|
| 28 |
0 |
@Override... |
| 29 |
|
public JobId align(List<SequenceI> toalign, WsParamSetI parameters, |
| 30 |
|
List<ArgumentI> arguments) throws Throwable |
| 31 |
|
{ |
| 32 |
0 |
List<compbio.data.sequence.FastaSequence> seqs = new ArrayList<>(); |
| 33 |
0 |
for (SequenceI seq : toalign) |
| 34 |
|
{ |
| 35 |
0 |
seqs.add(new FastaSequence(seq.getName(), seq.getSequenceAsString())); |
| 36 |
|
} |
| 37 |
0 |
String jobid = null; |
| 38 |
0 |
if (parameters != null) |
| 39 |
|
{ |
| 40 |
0 |
if (parameters instanceof JabaPreset) |
| 41 |
|
{ |
| 42 |
0 |
jobid = service.presetAlign(seqs, |
| 43 |
|
((JabaPreset) parameters).getJabaPreset()); |
| 44 |
|
} |
| 45 |
|
else |
| 46 |
|
{ |
| 47 |
0 |
jobid = service.customAlign(seqs, JabaParamStore |
| 48 |
|
.getJabafromJwsArgs(parameters.getArguments())); |
| 49 |
|
} |
| 50 |
|
} |
| 51 |
0 |
else if (arguments != null && arguments.size() > 0) |
| 52 |
|
{ |
| 53 |
0 |
jobid = service.customAlign(seqs, |
| 54 |
|
JabaParamStore.getJabafromJwsArgs(arguments)); |
| 55 |
|
} |
| 56 |
|
else |
| 57 |
|
{ |
| 58 |
0 |
jobid = service.align(seqs); |
| 59 |
|
} |
| 60 |
|
|
| 61 |
0 |
if (jobid == null) |
| 62 |
|
{ |
| 63 |
0 |
return null; |
| 64 |
|
} |
| 65 |
0 |
return new JobId(our.getServiceType(), our.getName(), jobid); |
| 66 |
|
} |
| 67 |
|
|
| |
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 3 |
Complexity Density: 0.23 |
|
| 68 |
0 |
@Override... |
| 69 |
|
public AlignmentI getAlignmentFor(JobId jobId) |
| 70 |
|
throws InvalidArgumentException, ServerError, IOError |
| 71 |
|
{ |
| 72 |
0 |
Alignment alignment = null; |
| 73 |
0 |
try |
| 74 |
|
{ |
| 75 |
0 |
alignment = service.getResult(jobId.getJobId()); |
| 76 |
|
} catch (ResultNotAvailableException rnotav) |
| 77 |
|
{ |
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
} |
| 82 |
0 |
SequenceI[] alseqs; |
| 83 |
0 |
int alseq_l = 0; |
| 84 |
0 |
if (alignment.getSequences().size() == 0) |
| 85 |
|
{ |
| 86 |
0 |
return null; |
| 87 |
|
} |
| 88 |
|
|
| 89 |
0 |
alseqs = new SequenceI[alignment.getSequences().size()]; |
| 90 |
0 |
for (compbio.data.sequence.FastaSequence seq : alignment.getSequences()) |
| 91 |
|
{ |
| 92 |
0 |
alseqs[alseq_l++] = new Sequence(seq.getId(), seq.getSequence()); |
| 93 |
|
} |
| 94 |
0 |
AlignmentI jv_al = new jalview.datamodel.Alignment(alseqs); |
| 95 |
0 |
jv_al.setGapCharacter(alignment.getMetadata().getGapchar()); |
| 96 |
0 |
return jv_al; |
| 97 |
|
|
| 98 |
|
} |
| 99 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 100 |
0 |
public JabawsMsaInstance(Jws2Instance handle)... |
| 101 |
|
{ |
| 102 |
0 |
super(handle); |
| 103 |
|
} |
| 104 |
|
|
| 105 |
|
} |