-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDNASearchDemo.java
More file actions
41 lines (35 loc) · 1.53 KB
/
DNASearchDemo.java
File metadata and controls
41 lines (35 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.util.ArrayList;
import java.util.List;
/**
* Demonstrate searching a DNA database with multiple scoring algorithms.
* @author Dr. Jody Paul
* @version 2026-03-10a
*/
public class DNASearchDemo {
static final SequenceScoringAlgorithm EXAMPLE_ALGORITHM = new ExamplePositionMatchAlgorithm();
/**
* Runs the example program.
*
* @param args command-line arguments; not used in this demo
*/
public static void main(String[] args) {
List<DNASequence> database = new ArrayList<>();
database.add(new DNASequence("Human_Example", "ACGTACGT"));
database.add(new DNASequence("Mouse_Example", "ACGTTCGT"));
database.add(new DNASequence("Fish_Example", "TTTTACGA"));
String query = "ACGTACGA";
List<SequenceScoringAlgorithm> algorithms = new ArrayList<>();
algorithms.add(EXAMPLE_ALGORITHM);
AlgorithmComparisonManager manager = new AlgorithmComparisonManager(algorithms);
List<MatchResult> results = manager.compareAll(query, database);
System.out.println("Query sequence: " + query);
System.out.println();
for (MatchResult result : results) {
System.out.println("Algorithm: " + result.getAlgorithmName());
System.out.println("Best match label: " + result.getBestSequence().getLabel());
System.out.println("Best match sequence: " + result.getBestSequence().getSequence());
System.out.println("Score: " + result.getScore());
System.out.println();
}
}
}