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