[927] | 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 |
|
---|
[1303] | 15 | package de.ugoe.cs.autoquest.plugin.alignment.commands;
|
---|
[205] | 16 |
|
---|
| 17 | import java.io.File;
|
---|
[425] | 18 | import java.io.FilenameFilter;
|
---|
[205] | 19 | import java.util.Collection;
|
---|
[1307] | 20 | import java.util.Iterator;
|
---|
[205] | 21 | import java.util.LinkedList;
|
---|
| 22 | import java.util.List;
|
---|
[639] | 23 | import java.util.logging.Level;
|
---|
[205] | 24 |
|
---|
[922] | 25 | import de.ugoe.cs.autoquest.CommandHelpers;
|
---|
| 26 | import de.ugoe.cs.autoquest.eventcore.Event;
|
---|
[1307] | 27 | import de.ugoe.cs.autoquest.plugin.alignment.SmithWaterman;
|
---|
| 28 | import de.ugoe.cs.autoquest.plugin.alignment.DifferenceSubstitutionMatrix;
|
---|
| 29 | import de.ugoe.cs.autoquest.plugin.alignment.seqgen.RandomSequenceGenerator;
|
---|
[205] | 30 | import de.ugoe.cs.util.console.Command;
|
---|
| 31 | import de.ugoe.cs.util.console.Console;
|
---|
[667] | 32 | import de.ugoe.cs.util.console.GlobalDataContainer;
|
---|
[205] | 33 |
|
---|
[206] | 34 | /**
|
---|
| 35 | * <p>
|
---|
[1303] | 36 | * Command to generate a binary alignment of two sequences
|
---|
[206] | 37 | * </p>
|
---|
| 38 | *
|
---|
| 39 | * @author Steffen Herbold
|
---|
| 40 | * @version 1.0
|
---|
| 41 | */
|
---|
[1307] | 42 | public class CMDbinaryAlignment implements Command {
|
---|
[205] | 43 |
|
---|
[206] | 44 | /*
|
---|
| 45 | * (non-Javadoc)
|
---|
| 46 | *
|
---|
| 47 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
| 48 | */
|
---|
[205] | 49 | @Override
|
---|
| 50 | public void run(List<Object> parameters) {
|
---|
[227] | 51 | String sequencesName;
|
---|
[1303] | 52 | String algorithm;
|
---|
[205] | 53 | try {
|
---|
[1303] | 54 | sequencesName = (String) parameters.get(0);
|
---|
| 55 | if (parameters.size() > 1) {
|
---|
| 56 | algorithm = (String) parameters.get(1);
|
---|
[205] | 57 | }
|
---|
| 58 | } catch (Exception e) {
|
---|
[766] | 59 | throw new IllegalArgumentException();
|
---|
[205] | 60 | }
|
---|
[206] | 61 |
|
---|
[556] | 62 | Collection<List<Event>> sequences = new LinkedList<List<Event>>();
|
---|
[1307] | 63 | sequences = (Collection<List<Event>>) GlobalDataContainer.getInstance()
|
---|
| 64 | .getData(sequencesName);
|
---|
| 65 | Console.println("Number of sequences: " + sequences.size());
|
---|
| 66 | for (Iterator<List<Event>> it = sequences.iterator(); it.hasNext();) {
|
---|
| 67 | List<Event> ev = it.next();
|
---|
| 68 | RandomSequenceGenerator randgen = new RandomSequenceGenerator(1,
|
---|
| 69 | 80, 10);
|
---|
| 70 | int[] seq1 = randgen.generate(ev);
|
---|
| 71 | int[] seq2 = randgen.generate(ev);
|
---|
| 72 | SmithWaterman sw = new SmithWaterman(seq1, seq2,
|
---|
| 73 | new DifferenceSubstitutionMatrix(seq1, seq2));
|
---|
[206] | 74 |
|
---|
[1307] | 75 | sw.printDPMatrix();
|
---|
| 76 | Console.println("Number of events in sequence: " + ev.size());
|
---|
| 77 | for (Iterator<Event> foo = ev.iterator(); foo.hasNext();) {
|
---|
| 78 | Event blubb = foo.next();
|
---|
| 79 | // Console.println(blubb.toString());
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 |
|
---|
[205] | 83 | }
|
---|
| 84 |
|
---|
[206] | 85 | /*
|
---|
| 86 | * (non-Javadoc)
|
---|
| 87 | *
|
---|
| 88 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
| 89 | */
|
---|
[205] | 90 | @Override
|
---|
[664] | 91 | public String help() {
|
---|
[1303] | 92 | return "binaryAlignment <sequencesName> {<algorithm>}";
|
---|
[205] | 93 | }
|
---|
| 94 |
|
---|
| 95 | }
|
---|