[1314] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany
|
---|
| 2 | //
|
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 4 | // you may not use this file except in compliance with the License.
|
---|
| 5 | // You may obtain a copy of the License at
|
---|
| 6 | //
|
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 8 | //
|
---|
| 9 | // Unless required by applicable law or agreed to in writing, software
|
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 12 | // See the License for the specific language governing permissions and
|
---|
| 13 | // limitations under the License.
|
---|
| 14 |
|
---|
| 15 | package de.ugoe.cs.autoquest.plugin.alignment.commands;
|
---|
| 16 |
|
---|
[1330] | 17 |
|
---|
[1314] | 18 | import java.util.Collection;
|
---|
| 19 | import java.util.LinkedList;
|
---|
| 20 | import java.util.List;
|
---|
| 21 |
|
---|
| 22 | import de.ugoe.cs.autoquest.eventcore.Event;
|
---|
| 23 | import de.ugoe.cs.autoquest.plugin.alignment.SmithWaterman;
|
---|
[1323] | 24 | import de.ugoe.cs.autoquest.plugin.alignment.seqgen.SimpleSequenceGenerator;
|
---|
| 25 | import de.ugoe.cs.autoquest.plugin.alignment.substitution.NearbySubstitutionMatrix;
|
---|
[1330] | 26 | import de.ugoe.cs.autoquest.plugin.alignment.substitution.ObjectDistanceSubstitionMatrix;
|
---|
[1314] | 27 | import de.ugoe.cs.util.console.Command;
|
---|
| 28 | import de.ugoe.cs.util.console.Console;
|
---|
| 29 | import de.ugoe.cs.util.console.GlobalDataContainer;
|
---|
| 30 |
|
---|
| 31 | /**
|
---|
| 32 | * <p>
|
---|
| 33 | * Command to generate a binary alignment of two sequences
|
---|
| 34 | * </p>
|
---|
| 35 | *
|
---|
[1330] | 36 | * @author Ralph Krimmel
|
---|
[1314] | 37 | * @version 1.0
|
---|
| 38 | */
|
---|
| 39 | public class CMDbinaryAlignment implements Command {
|
---|
| 40 |
|
---|
| 41 | /*
|
---|
| 42 | * (non-Javadoc)
|
---|
| 43 | *
|
---|
| 44 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
| 45 | */
|
---|
| 46 | public void run(List<Object> parameters) {
|
---|
[1446] | 47 | String sequencesName = "sequences";
|
---|
[1314] | 48 | String algorithm;
|
---|
| 49 | try {
|
---|
| 50 | sequencesName = (String) parameters.get(0);
|
---|
| 51 | if (parameters.size() > 1) {
|
---|
| 52 | algorithm = (String) parameters.get(1);
|
---|
| 53 | }
|
---|
| 54 | } catch (Exception e) {
|
---|
| 55 | throw new IllegalArgumentException();
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | Collection<List<Event>> sequences = new LinkedList<List<Event>>();
|
---|
[1330] | 59 | Object obj = GlobalDataContainer.getInstance().getData(sequencesName);
|
---|
| 60 | if(obj.getClass().equals(sequences.getClass())) {
|
---|
| 61 | sequences = (Collection<List<Event>>) obj;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 |
|
---|
| 66 |
|
---|
| 67 |
|
---|
[1323] | 68 | if(sequences != null) {
|
---|
| 69 | Console.println("Number of sequences: " + sequences.size());
|
---|
[1314] | 70 |
|
---|
[1323] | 71 | SimpleSequenceGenerator gen = new SimpleSequenceGenerator();
|
---|
| 72 | gen.generate(sequences);
|
---|
[1446] | 73 | int[] seq1 = gen.get(0).getSequence();
|
---|
| 74 | int[] seq2 = gen.get(0).getSequence();
|
---|
[1330] | 75 | ObjectDistanceSubstitionMatrix submat = new ObjectDistanceSubstitionMatrix();
|
---|
| 76 | submat.generate(sequences);
|
---|
[1323] | 77 | SmithWaterman sw = new SmithWaterman(seq1, seq2,
|
---|
| 78 | new NearbySubstitutionMatrix(seq1, seq2, 10));
|
---|
[1314] | 79 |
|
---|
[1330] | 80 | sw.printDPMatrix();
|
---|
[1323] | 81 | System.out.println();
|
---|
[1446] | 82 | sw.printAlignments();
|
---|
[1323] | 83 | // sw.getMatches();
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
[1314] | 86 |
|
---|
[1323] | 87 |
|
---|
[1314] | 88 | /*
|
---|
| 89 | * (non-Javadoc)
|
---|
| 90 | *
|
---|
| 91 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
| 92 | */
|
---|
| 93 | @Override
|
---|
| 94 | public String help() {
|
---|
| 95 | return "binaryAlignment <sequencesName> {<algorithm>}";
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | }
|
---|