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

Last change on this file since 1307 was 1307, checked in by rkrimmel, 11 years ago

Some tests for Smith Waterman Algorithm (temporary)

  • Property svn:mime-type set to text/plain
File size: 3.0 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
17import java.io.File;
18import java.io.FilenameFilter;
19import java.util.Collection;
20import java.util.Iterator;
21import java.util.LinkedList;
22import java.util.List;
23import java.util.logging.Level;
24
25import de.ugoe.cs.autoquest.CommandHelpers;
26import de.ugoe.cs.autoquest.eventcore.Event;
27import de.ugoe.cs.autoquest.plugin.alignment.SmithWaterman;
28import de.ugoe.cs.autoquest.plugin.alignment.DifferenceSubstitutionMatrix;
29import de.ugoe.cs.autoquest.plugin.alignment.seqgen.RandomSequenceGenerator;
30import de.ugoe.cs.util.console.Command;
31import de.ugoe.cs.util.console.Console;
32import de.ugoe.cs.util.console.GlobalDataContainer;
33
34/**
35 * <p>
36 * Command to generate a binary alignment of two sequences
37 * </p>
38 *
39 * @author Steffen Herbold
40 * @version 1.0
41 */
42public class CMDbinaryAlignment implements Command {
43
44        /*
45         * (non-Javadoc)
46         *
47         * @see de.ugoe.cs.util.console.Command#run(java.util.List)
48         */
49        @Override
50        public void run(List<Object> parameters) {
51                String sequencesName;
52                String algorithm;
53                try {
54                        sequencesName = (String) parameters.get(0);
55                        if (parameters.size() > 1) {
56                                algorithm = (String) parameters.get(1);
57                        }
58                } catch (Exception e) {
59                        throw new IllegalArgumentException();
60                }
61
62                Collection<List<Event>> sequences = new LinkedList<List<Event>>();
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));
74
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
83        }
84
85        /*
86         * (non-Javadoc)
87         *
88         * @see de.ugoe.cs.util.console.Command#help()
89         */
90        @Override
91        public String help() {
92                return "binaryAlignment <sequencesName> {<algorithm>}";
93        }
94
95}
Note: See TracBrowser for help on using the repository browser.