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.util.Collection;
|
---|
18 | import java.util.Iterator;
|
---|
19 | import java.util.LinkedList;
|
---|
20 | import java.util.List;
|
---|
21 | import java.util.logging.Level;
|
---|
22 |
|
---|
23 | import de.ugoe.cs.autoquest.eventcore.Event;
|
---|
24 | import de.ugoe.cs.autoquest.plugin.alignment.SmithWaterman;
|
---|
25 | import de.ugoe.cs.autoquest.plugin.alignment.seqgen.SimpleSequenceGenerator;
|
---|
26 | import de.ugoe.cs.autoquest.plugin.alignment.substitution.NearbySubstitutionMatrix;
|
---|
27 | import de.ugoe.cs.autoquest.plugin.alignment.substitution.ObjectDistanceSubstitionMatrix;
|
---|
28 | import de.ugoe.cs.util.console.Command;
|
---|
29 | import de.ugoe.cs.util.console.Console;
|
---|
30 | import de.ugoe.cs.util.console.GlobalDataContainer;
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * <p>
|
---|
34 | * Command to generate a binary alignment of two sequences
|
---|
35 | * </p>
|
---|
36 | *
|
---|
37 | * @author Ralph Krimmel
|
---|
38 | * @version 1.0
|
---|
39 | */
|
---|
40 | public class CMDdeleteShortSequences implements Command {
|
---|
41 |
|
---|
42 | /*
|
---|
43 | * (non-Javadoc)
|
---|
44 | *
|
---|
45 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
46 | */
|
---|
47 | @SuppressWarnings("unchecked")
|
---|
48 | public void run(List<Object> parameters) {
|
---|
49 | String sequencesName = "sequences";
|
---|
50 | int delcount = 0;
|
---|
51 | int limit = 10;
|
---|
52 | try {
|
---|
53 | sequencesName = (String) parameters.get(0);
|
---|
54 | if (parameters.size() > 1) {
|
---|
55 | try {
|
---|
56 | limit = Integer.parseInt((String) parameters.get(1));
|
---|
57 | }
|
---|
58 | catch (NumberFormatException e)
|
---|
59 | {
|
---|
60 | Console.traceln(Level.WARNING,"Parameter not an integer. Using the default value.");
|
---|
61 | }
|
---|
62 | }
|
---|
63 | } catch (Exception e) {
|
---|
64 | throw new IllegalArgumentException();
|
---|
65 | }
|
---|
66 |
|
---|
67 | Collection<List<Event>> sequences = new LinkedList<List<Event>>();
|
---|
68 | Object obj = GlobalDataContainer.getInstance().getData(sequencesName);
|
---|
69 | if (obj.getClass().equals(sequences.getClass())) {
|
---|
70 | sequences = (Collection<List<Event>>) obj;
|
---|
71 | }
|
---|
72 |
|
---|
73 | if (sequences != null) {
|
---|
74 | Console.println("Number of sequences: " + sequences.size());
|
---|
75 | Iterator<List<Event>> iter = sequences.iterator();
|
---|
76 | while(iter.hasNext()) {
|
---|
77 | if (iter.next().size() < limit) {
|
---|
78 | iter.remove();
|
---|
79 | delcount++;
|
---|
80 | }
|
---|
81 | }
|
---|
82 |
|
---|
83 | Console.traceln(Level.INFO, "Deleted "+ delcount + " short sequences from " + sequencesName);
|
---|
84 | }
|
---|
85 | }
|
---|
86 |
|
---|
87 | /*
|
---|
88 | * (non-Javadoc)
|
---|
89 | *
|
---|
90 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
91 | */
|
---|
92 | @Override
|
---|
93 | public String help() {
|
---|
94 | return "deleteShortSequences <sequence name>";
|
---|
95 | }
|
---|
96 |
|
---|
97 | }
|
---|