source: trunk/autoquest-plugin-alignment/src/main/java/de/ugoe/cs/autoquest/plugin/alignment/commands/CMDbinaryAlignment.java @ 1446

Last change on this file since 1446 was 1446, checked in by rkrimmel, 10 years ago

Changed default sequences name to "sequences"

File size: 2.9 KB
Line 
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
15package de.ugoe.cs.autoquest.plugin.alignment.commands;
16
17
18import java.util.Collection;
19import java.util.LinkedList;
20import java.util.List;
21
22import de.ugoe.cs.autoquest.eventcore.Event;
23import de.ugoe.cs.autoquest.plugin.alignment.SmithWaterman;
24import de.ugoe.cs.autoquest.plugin.alignment.seqgen.SimpleSequenceGenerator;
25import de.ugoe.cs.autoquest.plugin.alignment.substitution.NearbySubstitutionMatrix;
26import de.ugoe.cs.autoquest.plugin.alignment.substitution.ObjectDistanceSubstitionMatrix;
27import de.ugoe.cs.util.console.Command;
28import de.ugoe.cs.util.console.Console;
29import de.ugoe.cs.util.console.GlobalDataContainer;
30
31/**
32 * <p>
33 * Command to generate a binary alignment of two sequences
34 * </p>
35 *
36 * @author Ralph Krimmel
37 * @version 1.0
38 */
39public 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) {
47                String sequencesName = "sequences";
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>>();
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
68                                if(sequences != null) {
69                                        Console.println("Number of sequences: " + sequences.size());
70
71                                        SimpleSequenceGenerator gen = new SimpleSequenceGenerator();
72                                        gen.generate(sequences);
73                                        int[] seq1 = gen.get(0).getSequence();
74                                        int[] seq2 = gen.get(0).getSequence();
75                                        ObjectDistanceSubstitionMatrix submat = new ObjectDistanceSubstitionMatrix();
76                                        submat.generate(sequences);
77                                        SmithWaterman sw = new SmithWaterman(seq1, seq2,
78                                                        new NearbySubstitutionMatrix(seq1, seq2, 10));
79
80                                sw.printDPMatrix();
81                                System.out.println();
82                                sw.printAlignments();
83                                // sw.getMatches();
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}
Note: See TracBrowser for help on using the repository browser.