├── Releases
├── README.txt
└── SequenceMatrix-MacOSX-1.6.7
│ └── Sequence Matrix.app
│ └── Contents
│ ├── PkgInfo
│ ├── MacOS
│ └── JavaApplicationStub
│ ├── Resources
│ ├── GenericJavaApp.icns
│ └── Java
│ │ └── SequenceMatrix.jar
│ └── Info.plist
├── Release
├── SequenceMatrix
│ ├── SequenceMatrix.bat
│ └── Sample files
│ │ ├── Scathophagidae_Concatenation_check_batch.nex
│ │ ├── Example_1_Primates_fasta
│ │ └── atp8.fas
│ │ └── Example_1_Primates_tnt
│ │ └── atp8.tnt
└── SpeciesIdentifier
│ ├── SpeciesIdentifier.bat
│ └── SpeciesIdentifier Manual.pdf
├── nbproject
├── private
│ └── private.xml
├── ide-targets.xml
└── project.xml
├── src
├── main
│ └── java
│ │ └── com
│ │ └── ggvaidya
│ │ └── TaxonDNA
│ │ ├── Common
│ │ ├── DNA
│ │ │ ├── formats
│ │ │ │ ├── sequences-commands.txt
│ │ │ │ ├── FormatException.java
│ │ │ │ ├── FormatListener.java
│ │ │ │ ├── BaseFormatHandler.java
│ │ │ │ ├── Interleaver.java
│ │ │ │ ├── FormatHandlerEvent.java
│ │ │ │ ├── FormatHandler.java
│ │ │ │ └── SequencesHandler.java
│ │ │ ├── SequenceContainer.java
│ │ │ ├── SequenceListException.java
│ │ │ ├── SequenceException.java
│ │ │ ├── PairwiseDistance.java
│ │ │ ├── SpeciesDetail.java
│ │ │ ├── Testing.java
│ │ │ ├── Settings.java
│ │ │ └── FromToPair.java
│ │ ├── Versions.java
│ │ ├── UI
│ │ │ ├── DirectoryFilenameFilter.java
│ │ │ ├── UndoTask.java
│ │ │ ├── UndoStack.java
│ │ │ ├── CloseableWindow.java
│ │ │ ├── UIExtension.java
│ │ │ ├── DefaultButton.java
│ │ │ ├── ProgressBar.java
│ │ │ └── LargeTextArea.java
│ │ ├── DelayAbortedException.java
│ │ ├── TestController.java
│ │ ├── Testable.java
│ │ ├── DelayCallback.java
│ │ ├── Pearls.java
│ │ └── Others
│ │ │ └── UUID.java
│ │ ├── GenBankExplorer
│ │ ├── Preferences.java
│ │ ├── LociDisplayMode.java
│ │ ├── FeatureBin.java
│ │ └── DisplayMode.java
│ │ ├── SequenceMatrix
│ │ ├── Commands.java
│ │ └── Preferences.java
│ │ └── SpeciesIdentifier
│ │ ├── CommandLine.java
│ │ ├── SystemUsage.java
│ │ ├── Messages.java
│ │ └── ExportBySpeciesName.java
└── assemblies
│ ├── SequenceMatrix.xml
│ └── SpeciesIdentifier.xml
├── .mvn
└── jvm.config
├── Tests
├── SequenceMatrix
│ ├── basic.t
│ └── hang-during-split.t
├── best match
│ ├── test_missing
│ ├── test_HERE_atlast_is_missing
│ ├── test_here_is_not_missing
│ └── doesnt_add_up_to_100_bug.txt
└── alignmenthelperplugin
│ ├── test_missing
│ ├── test_HERE_atlast_is_missing
│ └── test_here_is_not_missing
├── .project
├── .github
└── workflows
│ ├── test.yaml
│ └── ci.yaml
├── .classpath
├── params.json
├── docs
├── stylesheets
│ ├── github-light.css
│ └── stylesheet.css
└── index.html
├── .gitignore
└── README.md
/Releases/README.txt:
--------------------------------------------------------------------------------
1 | This folder contains old releases of TaxonDNA.
2 |
--------------------------------------------------------------------------------
/Releases/SequenceMatrix-MacOSX-1.6.7/Sequence Matrix.app/Contents/PkgInfo:
--------------------------------------------------------------------------------
1 | APPL????
--------------------------------------------------------------------------------
/Release/SequenceMatrix/SequenceMatrix.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | %WINDIR%\System32\java.exe -Xmx1000M -jar SequenceMatrix.jar
3 |
--------------------------------------------------------------------------------
/Release/SpeciesIdentifier/SpeciesIdentifier.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | %WINDIR%\System32\java.exe -Xmx1000M -jar SpeciesIdentifier.jar
3 |
--------------------------------------------------------------------------------
/Release/SpeciesIdentifier/SpeciesIdentifier Manual.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gaurav/taxondna/HEAD/Release/SpeciesIdentifier/SpeciesIdentifier Manual.pdf
--------------------------------------------------------------------------------
/Releases/SequenceMatrix-MacOSX-1.6.7/Sequence Matrix.app/Contents/MacOS/JavaApplicationStub:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gaurav/taxondna/HEAD/Releases/SequenceMatrix-MacOSX-1.6.7/Sequence Matrix.app/Contents/MacOS/JavaApplicationStub
--------------------------------------------------------------------------------
/Releases/SequenceMatrix-MacOSX-1.6.7/Sequence Matrix.app/Contents/Resources/GenericJavaApp.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gaurav/taxondna/HEAD/Releases/SequenceMatrix-MacOSX-1.6.7/Sequence Matrix.app/Contents/Resources/GenericJavaApp.icns
--------------------------------------------------------------------------------
/Releases/SequenceMatrix-MacOSX-1.6.7/Sequence Matrix.app/Contents/Resources/Java/SequenceMatrix.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gaurav/taxondna/HEAD/Releases/SequenceMatrix-MacOSX-1.6.7/Sequence Matrix.app/Contents/Resources/Java/SequenceMatrix.jar
--------------------------------------------------------------------------------
/nbproject/private/private.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/formats/sequences-commands.txt:
--------------------------------------------------------------------------------
1 | COMMANDS USED BY SEQUENCES
2 |
3 | format: command\tfamilyCode\texplanation\n\t\t\texample
4 |
5 | N/A nucleotide Indicates that the sequence information is composed of nucleotides.
6 | cancelled sequencematrix Indicates that this sequence is a 'cancelled'
--------------------------------------------------------------------------------
/.mvn/jvm.config:
--------------------------------------------------------------------------------
1 | --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
2 |
--------------------------------------------------------------------------------
/Tests/SequenceMatrix/basic.t:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 |
3 | =head1 NAME
4 |
5 | basic.t
6 |
7 | =head2 GOALS
8 |
9 | Very basic tests for SequenceMatrix
10 |
11 | =cut
12 |
13 | use Test::More;
14 |
15 | plan(tests => 1);
16 |
17 | sub exec_sequence_matrix {
18 | system("/usr/bin/java",
19 | "-jar" => "../Release/SequenceMatrix.jar",
20 | @_
21 | );
22 | }
23 |
24 | exec_sequence_matrix(
25 | "--add" => "files/Diptera COI.fasta",
26 | "--add" => "files/coi_final.txt"
27 | );
28 |
29 | pass("Added two fasta files.");
30 |
--------------------------------------------------------------------------------
/Tests/SequenceMatrix/hang-during-split.t:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl -w
2 |
3 | =head1 NAME
4 |
5 | hang-during-split.t
6 |
7 | =head2 GOALS
8 |
9 | We have a case where SM hangs while loading a file.
10 | Let's test that?
11 |
12 | =cut
13 |
14 | use Test::More;
15 |
16 | plan(tests => 1);
17 |
18 | sub exec_sequence_matrix {
19 | system("/usr/bin/java",
20 | "-jar" => "../Release/SequenceMatrix.jar",
21 | @_
22 | );
23 | }
24 |
25 | exec_sequence_matrix(
26 | "--add" => "files/primates.nex",
27 | );
28 |
29 | pass("Added a Nexus file.");
30 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TaxonDNA
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/nbproject/ide-targets.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/assemblies/SequenceMatrix.xml:
--------------------------------------------------------------------------------
1 |
2 | SequenceMatrix
3 |
4 | zip
5 |
6 |
7 |
8 | Release/SequenceMatrix
9 |
10 | **
11 |
12 | .
13 |
14 |
15 |
16 | README*
17 | COPYING
18 |
19 |
20 |
21 |
22 |
23 | target/TaxonDNA-${pom.version}-SequenceMatrix.jar
24 | SequenceMatrix.jar
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/assemblies/SpeciesIdentifier.xml:
--------------------------------------------------------------------------------
1 |
2 | SpeciesIdentifier
3 |
4 | zip
5 |
6 |
7 |
8 | Release/SpeciesIdentifier
9 |
10 | **
11 |
12 | .
13 |
14 |
15 |
16 | README*
17 | COPYING
18 |
19 |
20 |
21 |
22 |
23 | target/TaxonDNA-${project.version}-SpeciesIdentifier.jar
24 | SpeciesIdentifier.jar
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/.github/workflows/test.yaml:
--------------------------------------------------------------------------------
1 | name: Test with Maven
2 |
3 | on:
4 | push:
5 | branches:
6 | - develop
7 | - master
8 | pull_request:
9 | branches:
10 | - develop
11 | - master
12 |
13 | jobs:
14 | build:
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v3
19 | - name: Set up JDK 17
20 | uses: actions/setup-java@v3
21 | with:
22 | # See https://github.com/actions/setup-java#supported-distributions
23 | # for list of distributions.
24 | distribution: 'temurin'
25 | java-version: '17'
26 | cache: maven
27 | - name: Test with Maven
28 | run: mvn -B test
29 | - name: Check style with Spotless
30 | run: mvn -B spotless:check
31 | - name: Build with Maven
32 | run: mvn -B package
33 |
34 |
--------------------------------------------------------------------------------
/Tests/best match/test_missing:
--------------------------------------------------------------------------------
1 | >seqU1147159630510_2
2 | --------------------------------------------------------------------------------
3 | --------------------------------------------------------------------------------
4 | --------------------------------------------------------------------------------
5 | --------------------------------------------------------------------------------
6 | --------------------------------------------------------------------------------
7 | --------------------------------------------------------------------------------
8 | --------------------------------------------------------------------------------
9 | --------------------------------------------------------------------------------
10 | --------------------------------------------------------------------------------
11 | --------------------------------------------------------------------------------
12 | --------------------------------------------------------------------------------
13 | --------------------------------------------------------------------------------
14 | --------------------------------------------------------------------------------
15 | ----------
16 |
--------------------------------------------------------------------------------
/Tests/alignmenthelperplugin/test_missing:
--------------------------------------------------------------------------------
1 | >seqU1147159630510_2
2 | --------------------------------------------------------------------------------
3 | --------------------------------------------------------------------------------
4 | --------------------------------------------------------------------------------
5 | --------------------------------------------------------------------------------
6 | --------------------------------------------------------------------------------
7 | --------------------------------------------------------------------------------
8 | --------------------------------------------------------------------------------
9 | --------------------------------------------------------------------------------
10 | --------------------------------------------------------------------------------
11 | --------------------------------------------------------------------------------
12 | --------------------------------------------------------------------------------
13 | --------------------------------------------------------------------------------
14 | --------------------------------------------------------------------------------
15 | ----------
16 |
--------------------------------------------------------------------------------
/Tests/best match/test_HERE_atlast_is_missing:
--------------------------------------------------------------------------------
1 | >Test test [uniqueid:1147159630464_2]
2 | ATGAATCCTCAGGCAAAACTAATCTTCGTCATCAGCTTACTCCTAGGATCAACCATCACAATCTCAAGCA
3 | ACCATTGAGTTATGGCCTGAACCGGGCTTGAGATCAACACACTAGCCATCCTCCCCCTAATCTCAAAATC
4 | CCACCACCCCCGTGCTATCGAGGCAGCAACCAAATACTTTCTGGTCCAAGCAGCTGCTTCTGCCTTAGTG
5 | TTATTCTCTAGCATA------ACCAATGCATGATACACCGGACAATGAGACATTACACAGCTAACGCACC
6 | CAACATCCTGCCTGGTCCTAACAGCAGCCATCGCCATAAAATTAGGTCTAGTTCCGTTCCACTTTTGATT
7 | CCCTGAAGTTCTCCAAGGTACTTCCCTAGTCACTAGCCTCCTACTATCAACAGCCATAAAATTTCCACCG
8 | ATCACCCTACTATACCTCACCTCCAACTCATTAAACCCTTCATTATTGGTTACTATGGCCATTCTATCCA
9 | CAGCCCTAGGAGGATGAATAGGCCTCAACCAAACACAAATCCGTAAAATCTTGGCTTTCTCCTCTATTTC
10 | ACATCTAGGCTGAATGGCCATTATTCTCTCCTACAATCCTAAACTAACCCTACTAAACTTCTATCTATAC
11 | AGCCTAATAACCGCAACTGTATTTCTCACCCTGAACACCATAAAAGCTCTAAAACTATCAACACTAATAA
12 | CTGCATGAACAAAAACTCCATCCCTCAGCACCATCCTCGTCATCACACTACTTTCCCTGGCTGGCCTCCC
13 | TCCACTGACAGGTTTCCTGCCCAAATGACTCATCATCCAAGAGCTTACCAAACAGGATATAGCCCTCACA
14 | GCATTACTTATCTCCATACTCTCACTGCTTAGCCTGTTCTTCTACCTCCGTCTCGCATACTGCACAGCAA
15 | TCACGCTTCCTCCTCATACGACAAATCACATGAAACTATGGCACGTTAACAAA------CCAACCAATAC
16 | CTCAATCGCCGTCTTGGCCACCCTATCCATCACCCTCCTCCCCCTTTCCCCCATACTACTCGCCATTGTT
17 |
18 |
--------------------------------------------------------------------------------
/Tests/best match/test_here_is_not_missing:
--------------------------------------------------------------------------------
1 | >Test testee [uniqueid:1147159630510_2]
2 | ----------------------------------------------------------------------
3 | ----------------------------------------------------------------------
4 | ----------------------------------------------------------------------
5 | ----------------------------------------------------------------------
6 | ----------------------------------------------------------------------
7 | ----------------------------------------------------------------------
8 | ----------------------------------------------------------------------
9 | ----------------------------------------------------------------------
10 | ----------------------------------------------------------------------
11 | ----------------------------------------------------------------------
12 | ----------------------------------------------------------------------
13 | ----------------------------------------------------------------------
14 | ----------------------------------------------------------------------
15 | ----------------------------------------------------------------------
16 | ----------------------------------------------------------------------
17 |
18 |
--------------------------------------------------------------------------------
/Tests/alignmenthelperplugin/test_HERE_atlast_is_missing:
--------------------------------------------------------------------------------
1 | >Test test [uniqueid:1147159630464_2]
2 | ATGAATCCTCAGGCAAAACTAATCTTCGTCATCAGCTTACTCCTAGGATCAACCATCACAATCTCAAGCA
3 | ACCATTGAGTTATGGCCTGAACCGGGCTTGAGATCAACACACTAGCCATCCTCCCCCTAATCTCAAAATC
4 | CCACCACCCCCGTGCTATCGAGGCAGCAACCAAATACTTTCTGGTCCAAGCAGCTGCTTCTGCCTTAGTG
5 | TTATTCTCTAGCATA------ACCAATGCATGATACACCGGACAATGAGACATTACACAGCTAACGCACC
6 | CAACATCCTGCCTGGTCCTAACAGCAGCCATCGCCATAAAATTAGGTCTAGTTCCGTTCCACTTTTGATT
7 | CCCTGAAGTTCTCCAAGGTACTTCCCTAGTCACTAGCCTCCTACTATCAACAGCCATAAAATTTCCACCG
8 | ATCACCCTACTATACCTCACCTCCAACTCATTAAACCCTTCATTATTGGTTACTATGGCCATTCTATCCA
9 | CAGCCCTAGGAGGATGAATAGGCCTCAACCAAACACAAATCCGTAAAATCTTGGCTTTCTCCTCTATTTC
10 | ACATCTAGGCTGAATGGCCATTATTCTCTCCTACAATCCTAAACTAACCCTACTAAACTTCTATCTATAC
11 | AGCCTAATAACCGCAACTGTATTTCTCACCCTGAACACCATAAAAGCTCTAAAACTATCAACACTAATAA
12 | CTGCATGAACAAAAACTCCATCCCTCAGCACCATCCTCGTCATCACACTACTTTCCCTGGCTGGCCTCCC
13 | TCCACTGACAGGTTTCCTGCCCAAATGACTCATCATCCAAGAGCTTACCAAACAGGATATAGCCCTCACA
14 | GCATTACTTATCTCCATACTCTCACTGCTTAGCCTGTTCTTCTACCTCCGTCTCGCATACTGCACAGCAA
15 | TCACGCTTCCTCCTCATACGACAAATCACATGAAACTATGGCACGTTAACAAA------CCAACCAATAC
16 | CTCAATCGCCGTCTTGGCCACCCTATCCATCACCCTCCTCCCCCTTTCCCCCATACTACTCGCCATTGTT
17 |
18 |
--------------------------------------------------------------------------------
/Tests/alignmenthelperplugin/test_here_is_not_missing:
--------------------------------------------------------------------------------
1 | >Test testee [uniqueid:1147159630510_2]
2 | ----------------------------------------------------------------------
3 | ----------------------------------------------------------------------
4 | ----------------------------------------------------------------------
5 | ----------------------------------------------------------------------
6 | ----------------------------------------------------------------------
7 | ----------------------------------------------------------------------
8 | ----------------------------------------------------------------------
9 | ----------------------------------------------------------------------
10 | ----------------------------------------------------------------------
11 | ----------------------------------------------------------------------
12 | ----------------------------------------------------------------------
13 | ----------------------------------------------------------------------
14 | ----------------------------------------------------------------------
15 | ----------------------------------------------------------------------
16 | ----------------------------------------------------------------------
17 |
18 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yaml:
--------------------------------------------------------------------------------
1 | # A GitHub Action to run code format checks and (eventually) testing.
2 | # Based on https://github.com/diffplug/spotless/blob/2baab0c62dcec9861109a63c1f97955736d76c70/.github/workflows/ci.yml
3 |
4 | on:
5 | pull_request:
6 |
7 | concurrency:
8 | group: ${{ github.workflow }}-${{ github.ref }}
9 | cancel-in-progress: true
10 |
11 | jobs:
12 | ci:
13 | runs-on: ubuntu-latest
14 | strategy:
15 | matrix:
16 | javaVersion: [ '17', '21', '23' ]
17 | name: Code formatting checks on Temurin Java ${{ matrix.JavaVersion }}
18 | env:
19 | buildcacheuser: ${{ secrets.BUILDCACHE_USER }}
20 | buildcachepass: ${{ secrets.BUILDCACHE_PASS }}
21 | steps:
22 | - name: Checkout
23 | uses: actions/checkout@v4
24 | with:
25 | fetch-depth: 0
26 | - name: Install Temurin Java ${{ matrix.JavaVersion }}
27 | uses: actions/setup-java@v4
28 | with:
29 | distribution: "temurin"
30 | java-version: ${{ matrix.JavaVersion }}
31 | cache: 'maven'
32 | - name: Check code formatting with Spotless
33 | run: mvn -B spotless:check
34 | - name: Check that we can build the project
35 | run: mvn -B package
36 |
--------------------------------------------------------------------------------
/Releases/SequenceMatrix-MacOSX-1.6.7/Sequence Matrix.app/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleAllowMixedLocalizations
6 | true
7 | CFBundleDevelopmentRegion
8 | English
9 | CFBundleExecutable
10 | JavaApplicationStub
11 | CFBundleIconFile
12 | GenericJavaApp.icns
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | Sequence Matrix
17 | CFBundlePackageType
18 | APPL
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 100.0
23 | Java
24 |
25 | ClassPath
26 | $JAVAROOT/SequenceMatrix.jar
27 | JVMVersion
28 | 1.4+
29 | MainClass
30 | com.ggvaidya.TaxonDNA.SequenceMatrix.SequenceMatrix
31 | VMOptions
32 | -Xmx1024m
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/Versions.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Versions contains various constants and values used by TaxonDNA in general.
3 | *
4 | * @author Gaurav Vaidya gaurav@ggvaidya.com
5 | */
6 |
7 | /*
8 | * TaxonDNA
9 | * Copyright (C) 2005-10 Gaurav Vaidya
10 | *
11 | * This program is free software; you can redistribute it and/or modify
12 | * it under the terms of the GNU General Public License as published by
13 | * the Free Software Foundation; either version 2 of the License, or
14 | * (at your option) any later version.
15 | *
16 | * This program is distributed in the hope that it will be useful,
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | * GNU General Public License for more details.
20 | *
21 | * You should have received a copy of the GNU General Public License
22 | * along with this program; if not, write to the Free Software
23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 | *
25 | */
26 |
27 | package com.ggvaidya.TaxonDNA.Common;
28 |
29 | public class Versions {
30 | /** Returns the common version string for the entire TaxonDNA package. */
31 | public static String getTaxonDNA() {
32 | return Versions.class.getPackage().getImplementationVersion();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/UI/DirectoryFilenameFilter.java:
--------------------------------------------------------------------------------
1 | /** A FilenameFilter which only displays directory names. Won't work on Win32, though. */
2 | /*
3 | TaxonDNA
4 | Copyright (C) 2006 Gaurav Vaidya
5 |
6 | This program is free software; you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation; either version 2 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program; if not, write to the Free Software
18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 | package com.ggvaidya.TaxonDNA.Common.UI;
21 |
22 | import java.io.*;
23 |
24 | public class DirectoryFilenameFilter implements FilenameFilter {
25 | public DirectoryFilenameFilter() {
26 | // What more can I say?
27 | }
28 |
29 | public boolean accept(File dir, String name) {
30 | File file = new File(dir, name);
31 |
32 | System.err.println("Testing " + file);
33 |
34 | if (file.isDirectory()) return true;
35 |
36 | return false;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/UI/UndoTask.java:
--------------------------------------------------------------------------------
1 | /**
2 | * An UndoTask is a task which can be undoed. It is used by UndoStack to keep track of what's going
3 | * on, and allows us to be a little more flexible with our tasks.
4 | */
5 | /*
6 | TaxonDNA
7 | Copyright (C) 2005 Gaurav Vaidya
8 |
9 | This program is free software; you can redistribute it and/or modify
10 | it under the terms of the GNU General Public License as published by
11 | the Free Software Foundation; either version 2 of the License, or
12 | (at your option) any later version.
13 |
14 | This program is distributed in the hope that it will be useful,
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | GNU General Public License for more details.
18 |
19 | You should have received a copy of the GNU General Public License
20 | along with this program; if not, write to the Free Software
21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 | */
23 | package com.ggvaidya.TaxonDNA.Common.UI;
24 |
25 | public class UndoTask {
26 | // use these or make your own!
27 | public static final int UNDO_ADD = 0;
28 | public static final int UNDO_DELETE = 0;
29 |
30 | private int type = 0;
31 | private Object target = null;
32 |
33 | public UndoTask(int type, Object target) {
34 | this.type = type;
35 | this.target = target;
36 | }
37 |
38 | public int getType() {
39 | return type;
40 | }
41 |
42 | public Object getTarget() {
43 | return target;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DelayAbortedException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * A DelayAbortedException means that a DelayCallback needs to let the Delay know to stop, stop now,
3 | * probably because the user wants it to.
4 | *
5 | * @author Gaurav Vaidya, gaurav@ggvaidya.com
6 | */
7 |
8 | /*
9 | * TaxonDNA
10 | * Copyright (C) 2005 Gaurav Vaidya
11 | *
12 | * This program is free software; you can redistribute it and/or modify
13 | * it under the terms of the GNU General Public License as published by
14 | * the Free Software Foundation; either version 2 of the License, or
15 | * (at your option) any later version.
16 | *
17 | * This program is distributed in the hope that it will be useful,
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | * GNU General Public License for more details.
21 | *
22 | * You should have received a copy of the GNU General Public License
23 | * along with this program; if not, write to the Free Software
24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 | *
26 | *
27 | */
28 |
29 | package com.ggvaidya.TaxonDNA.Common;
30 |
31 | public class DelayAbortedException extends Exception {
32 | /** A generated serialVersionUID */
33 | private static final long serialVersionUID = -470511092703466979L;
34 |
35 | public DelayAbortedException() {
36 | super();
37 | }
38 |
39 | public DelayAbortedException(String message) {
40 | super(message);
41 | }
42 |
43 | public DelayAbortedException(String message, Throwable cause) {
44 | super(message, cause);
45 | }
46 |
47 | public DelayAbortedException(Throwable cause) {
48 | super(cause);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/formats/FormatException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * A FormatException is thrown if any of the formats here don't like something. FormatException is a
3 | * generic error meaning "something went wrong trying to figure this format out"; it could be an
4 | * IOException, SequenceSetException, etc. We wrap it all up, but you can get the underlying
5 | * exception by using getCause().
6 | */
7 |
8 | /*
9 | TaxonDNA
10 | Copyright (C) 2005 Gaurav Vaidya
11 |
12 | This program is free software; you can redistribute it and/or modify
13 | it under the terms of the GNU General Public License as published by
14 | the Free Software Foundation; either version 2 of the License, or
15 | (at your option) any later version.
16 |
17 | This program is distributed in the hope that it will be useful,
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | GNU General Public License for more details.
21 |
22 | You should have received a copy of the GNU General Public License
23 | along with this program; if not, write to the Free Software
24 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 | */
26 |
27 | package com.ggvaidya.TaxonDNA.Common.DNA.formats;
28 |
29 | public class FormatException extends Exception {
30 | private static final long serialVersionUID = -8796431763478134968L;
31 |
32 | public FormatException() {
33 | super();
34 | }
35 |
36 | public FormatException(String message) {
37 | super(message);
38 | }
39 |
40 | public FormatException(String message, Throwable cause) {
41 | super(message, cause);
42 | }
43 |
44 | public FormatException(Throwable cause) {
45 | super(cause);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/SequenceContainer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * A SequenceContainer contains sequence information, which can be accessed via its
3 | * getAsSequenceList() function. That's, err, it, really.
4 | */
5 | /*
6 | TaxonDNA
7 | Copyright (C) Gaurav Vaidya, 2007
8 |
9 | This program is free software; you can redistribute it and/or modify
10 | it under the terms of the GNU General Public License as published by
11 | the Free Software Foundation; either version 2 of the License, or
12 | (at your option) any later version.
13 |
14 | This program is distributed in the hope that it will be useful,
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | GNU General Public License for more details.
18 |
19 | You should have received a copy of the GNU General Public License
20 | along with this program; if not, write to the Free Software
21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 | */
23 |
24 | package com.ggvaidya.TaxonDNA.Common.DNA;
25 |
26 | import java.util.*;
27 |
28 | public interface SequenceContainer {
29 | /**
30 | * Returns a SequenceList containing all the sequences 'contained' herein. Might just contain a
31 | * single sequence.
32 | *
33 | * @throws SequenceException if there was a problem in retrieving or creating the one sequence
34 | * (e.g. if the sequence is hosted remotely, and the server returned an error).
35 | */
36 | SequenceList getAsSequenceList() throws SequenceException;
37 |
38 | /**
39 | * Returns a List contains all the other SequenceContainers that this SequenceContainer
40 | * 'contains'.
41 | *
42 | * @return aforementioned list, or an EMPTY list (NEVER null)
43 | */
44 | List alsoContains();
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/TestController.java:
--------------------------------------------------------------------------------
1 | /**
2 | * A TestController carries out Tests by calling the 'test()' method of Testable objects. The test
3 | * signals results back to TestController via four methods: testInformation(title, description),
4 | * testBegin(title), testSuccess(title), testFailure(title, description).
5 | *
6 | *
The Testable objects are responsible for their own issues - the TestController will only
7 | * report test status back to the user.
8 | *
9 | * @author Gaurav Vaidya gaurav@ggvaidya.com
10 | */
11 |
12 | /*
13 | * TaxonDNA
14 | * Copyright (C) 2005 Gaurav Vaidya
15 | *
16 | * This program is free software; you can redistribute it and/or modify
17 | * it under the terms of the GNU General Public License as published by
18 | * the Free Software Foundation; either version 2 of the License, or
19 | * (at your option) any later version.
20 | *
21 | * This program is distributed in the hope that it will be useful,
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 | * GNU General Public License for more details.
25 | *
26 | * You should have received a copy of the GNU General Public License
27 | * along with this program; if not, write to the Free Software
28 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 | *
30 | */
31 |
32 | package com.ggvaidya.TaxonDNA.Common;
33 |
34 | import java.io.*;
35 |
36 | public interface TestController {
37 | void begin(String title);
38 |
39 | void done();
40 |
41 | void beginTest(String testName);
42 |
43 | void failed(String description);
44 |
45 | void succeeded();
46 |
47 | void information(String information);
48 |
49 | File file(String name);
50 |
51 | File tempfile();
52 |
53 | boolean isIdentical(File x, File y);
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/Testable.java:
--------------------------------------------------------------------------------
1 | /**
2 | * A Testable class is one which can be tested. That wasn't too hard. To specify in additional
3 | * detail, all Testable objects have a function called 'test()', which runs a series of tests. The
4 | * results are signalled back to the caller via a callback mechanism (see Common.TestController).
5 | *
6 | * @author Gaurav Vaidya gaurav@ggvaidya.com
7 | */
8 |
9 | /*
10 | * TaxonDNA
11 | * Copyright (C) 2005 Gaurav Vaidya
12 | *
13 | * This program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program; if not, write to the Free Software
25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 | *
27 | */
28 |
29 | package com.ggvaidya.TaxonDNA.Common;
30 |
31 | public interface Testable {
32 | /**
33 | * The test which is used to test this object. Results are signalled to the TestController via
34 | * the passed TestController interface.
35 | *
36 | *
Since 'test' might take a while, a DelayCallback can be used to let the user know.
37 | *
38 | *
This really ought to be static, but this Cannot Be in the java world. So I'm going to rely
39 | * on implementations of 'test' to not confuse themselves with the core class itself.
40 | */
41 | void test(TestController controller, DelayCallback delay) throws DelayAbortedException;
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/SequenceListException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * A SequenceListException is thrown if there is something funny about a SequenceListException.
3 | * Mostly, this is about mistakes on the user's part (duplicate sequences).
4 | *
5 | *
Unlike the SequenceSetException (which is serious deprecated anyway), we roll
6 | * SequenceExceptions INTO ourself. A SequenceListException is ONLY thrown by a SequenceList
7 | * constructor; i.e. if there's an error loading up a SequenceList from a file.
8 | */
9 |
10 | /*
11 | TaxonDNA
12 | Copyright (C) 2005 Gaurav Vaidya
13 |
14 | This program is free software; you can redistribute it and/or modify
15 | it under the terms of the GNU General Public License as published by
16 | the Free Software Foundation; either version 2 of the License, or
17 | (at your option) any later version.
18 |
19 | This program is distributed in the hope that it will be useful,
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | GNU General Public License for more details.
23 |
24 | You should have received a copy of the GNU General Public License
25 | along with this program; if not, write to the Free Software
26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 | */
28 |
29 | package com.ggvaidya.TaxonDNA.Common.DNA;
30 |
31 | public class SequenceListException extends Exception {
32 | private static final long serialVersionUID = 485570581694822010L;
33 |
34 | public SequenceListException() {
35 | super();
36 | }
37 |
38 | public SequenceListException(String message) {
39 | super(message);
40 | }
41 |
42 | public SequenceListException(String message, Throwable cause) {
43 | super(message, cause);
44 | }
45 |
46 | public SequenceListException(Throwable cause) {
47 | super(cause);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/.classpath:
--------------------------------------------------------------------------------
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 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/formats/FormatListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * This is the final keystone in the FormatHandler system - it was cheap, easy and flexible, but now
3 | * it gets to be cheaply extensible too. In a nutshell, this is just an ordinary 'listener' for
4 | * FormatHandlers: you can 'listen' to a variety of events, using a simple constant system to
5 | * differentiate potentially subtle and complicated events.
6 | *
7 | *
The really huge question: should listeners get to push content directly into the output file?
8 | * How should this work? I'll just ignore it until a more appropriate time :).
9 | */
10 |
11 | /*
12 | TaxonDNA
13 | Copyright (C) 2005, 2006 Gaurav Vaidya
14 |
15 | This program is free software; you can redistribute it and/or modify
16 | it under the terms of the GNU General Public License as published by
17 | the Free Software Foundation; either version 2 of the License, or
18 | (at your option) any later version.
19 |
20 | This program is distributed in the hope that it will be useful,
21 | but WITHOUT ANY WARRANTY; without even the implied warranty of
22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 | GNU General Public License for more details.
24 |
25 | You should have received a copy of the GNU General Public License
26 | along with this program; if not, write to the Free Software
27 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 | */
29 |
30 | package com.ggvaidya.TaxonDNA.Common.DNA.formats;
31 |
32 | public interface FormatListener {
33 | /**
34 | * An 'event' occured while reading a file. This is going to vary *dramatically* between
35 | * different formats: I imagine Fasta is not going to report ANYTHING (except maybe
36 | * SEQUENCE_ADDEDs), while Nexus is probably going to go ballistic with SET_INFORMATION or
37 | * whatever.
38 | *
39 | * @throws FormatException if we see something we disapprove of; the FormatException will be
40 | * communicated back to the user.
41 | * @return true, if the event was 'consumed' (we shouldn't let anybody else know about this)
42 | */
43 | boolean eventOccured(FormatHandlerEvent evt) throws FormatException;
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/UI/UndoStack.java:
--------------------------------------------------------------------------------
1 | /**
2 | * An UndoStack encapsulated a Stack which keeps a list of 'tasks' executed. Tasks are defined by
3 | * UI.UndoTask.
4 | *
5 | *
One important thing which UndoStack needs to be capable of doing is to be as memory efficient
6 | * as possible. It's likely that once an object is deleted, we will be the only people to refer to
7 | * it; thus, it is our responsibility to free it as soon as is feasible.
8 | */
9 |
10 | /*
11 | TaxonDNA
12 | Copyright (C) 2005 Gaurav Vaidya
13 |
14 | This program is free software; you can redistribute it and/or modify
15 | it under the terms of the GNU General Public License as published by
16 | the Free Software Foundation; either version 2 of the License, or
17 | (at your option) any later version.
18 |
19 | This program is distributed in the hope that it will be useful,
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | GNU General Public License for more details.
23 |
24 | You should have received a copy of the GNU General Public License
25 | along with this program; if not, write to the Free Software
26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 | */
28 |
29 | package com.ggvaidya.TaxonDNA.Common.UI;
30 |
31 | public class UndoStack {
32 | private UndoTask[] tasks;
33 |
34 | public UndoStack(int size) {
35 | tasks = new UndoTask[size];
36 | }
37 |
38 | public int getSize() {
39 | return tasks.length;
40 | }
41 |
42 | public UndoTask getTask(int x) {
43 | if (x < tasks.length) return tasks[x];
44 | return null;
45 | }
46 |
47 | public void push(UndoTask push) {
48 | tasks[0] = null; // die, old task, die!
49 | for (int x = 1; x < tasks.length - 1; x++) {
50 | tasks[x - 1] = tasks[x]; // shift up
51 | }
52 | tasks[tasks.length - 1] = push; // last one is shifted into [$#tasks], in perl terms
53 | }
54 |
55 | public UndoTask pop() {
56 | for (int x = 1; x < tasks.length - 1; x++) {
57 | // ***************
58 | }
59 | return null;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Tests/best match/doesnt_add_up_to_100_bug.txt:
--------------------------------------------------------------------------------
1 | >Test test
2 | ATGAATCCTCAGGCAAAACTAATCTTCGTCATCAGCTTACTCCTAGGATCAACCATCACAATCTCAAGCA
3 | ACCATTGAGTTATGGCCTGAACCGGGCTTGAGATCAACACACTAGCCATCCTCCCCCTAATCTCAAAATC
4 | CCACCACCCCCGTGCTATCGAGGCAGCAACCAAATACTTTCTGGTCCAAGCAGCTGCTTCTGCCTTAGTG
5 | TTATTCTCTAGCATA------ACCAATGCATGATACACCGGACAATGAGACATTACACAGCTAACGCACC
6 | CAACATCCTGCCTGGTCCTAACAGCAGCCATCGCCATAAAATTAGGTCTAGTTCCGTTCCACTTTTGATT
7 | CCCTGAAGTTCTCCAAGGTACTTCCCTAGTCACTAGCCTCCTACTATCAACAGCCATAAAATTTCCACCG
8 | ATCACCCTACTATACCTCACCTCCAACTCATTAAACCCTTCATTATTGGTTACTATGGCCATTCTATCCA
9 | CAGCCCTAGGAGGATGAATAGGCCTCAACCAAACACAAATCCGTAAAATCTTGGCTTTCTCCTCTATTTC
10 | ACATCTAGGCTGAATGGCCATTATTCTCTCCTACAATCCTAAACTAACCCTACTAAACTTCTATCTATAC
11 | AGCCTAATAACCGCAACTGTATTTCTCACCCTGAACACCATAAAAGCTCTAAAACTATCAACACTAATAA
12 | CTGCATGAACAAAAACTCCATCCCTCAGCACCATCCTCGTCATCACACTACTTTCCCTGGCTGGCCTCCC
13 | TCCACTGACAGGTTTCCTGCCCAAATGACTCATCATCCAAGAGCTTACCAAACAGGATATAGCCCTCACA
14 | GCATTACTTATCTCCATACTCTCACTGCTTAGCCTGTTCTTCTACCTCCGTCTCGCATACTGCACAGCAA
15 | TCACGCTTCCTCCTCATACGACAAATCACATGAAACTATGGCACGTTAACAAA------CCAACCAATAC
16 | CTCAATCGCCGTCTTGGCCACCCTATCCATCACCCTCCTCCCCCTTTCCCCCATACTACTCGCCATTGTT
17 |
18 | >Test testee
19 | ----------------------------------------------------------------------
20 | ----------------------------------------------------------------------
21 | ----------------------------------------------------------------------
22 | ----------------------------------------------------------------------
23 | ----------------------------------------------------------------------
24 | ----------------------------------------------------------------------
25 | ----------------------------------------------------------------------
26 | ----------------------------------------------------------------------
27 | ----------------------------------------------------------------------
28 | ----------------------------------------------------------------------
29 | ----------------------------------------------------------------------
30 | ----------------------------------------------------------------------
31 | ----------------------------------------------------------------------
32 | ----------------------------------------------------------------------
33 | ----------------------------------------------------------------------
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/SequenceException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * A SequenceException is thrown if a sequence is wrong for some reason. `Wrong' includes having
3 | * non-valid nucleotides, length/sequence disparity, and anything else the Sequence class might need
4 | * to communicate with the user.
5 | */
6 |
7 | /*
8 | TaxonDNA
9 | Copyright (C) 2005 Gaurav Vaidya
10 |
11 | This program is free software; you can redistribute it and/or modify
12 | it under the terms of the GNU General Public License as published by
13 | the Free Software Foundation; either version 2 of the License, or
14 | (at your option) any later version.
15 |
16 | This program is distributed in the hope that it will be useful,
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | GNU General Public License for more details.
20 |
21 | You should have received a copy of the GNU General Public License
22 | along with this program; if not, write to the Free Software
23 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 | */
25 |
26 | package com.ggvaidya.TaxonDNA.Common.DNA;
27 |
28 | public class SequenceException extends Exception {
29 | /** A generated serialVersionUID */
30 | private static final long serialVersionUID = -2662237531930486828L;
31 |
32 | private String fullName = "";
33 |
34 | public String getMalformedSequenceName() {
35 | if (fullName.isEmpty()) return "(I can't understand the name either!)";
36 |
37 | return fullName;
38 | }
39 |
40 | public SequenceException(String name, String message) {
41 | super(message);
42 |
43 | fullName = name;
44 | }
45 |
46 | public SequenceException(String name, String message, Throwable cause) {
47 | super(message, cause);
48 |
49 | fullName = name;
50 | }
51 |
52 | public SequenceException(String name, Throwable cause) {
53 | super(cause);
54 |
55 | fullName = name;
56 | }
57 |
58 | public String getMessage() {
59 | return "While processing the sequence named '"
60 | + fullName
61 | + "', the following occured: "
62 | + super.getMessage();
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DelayCallback.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Interface for DelayCallbacks. Used to keep track of a long process. A function taking a long time
3 | * can call the DelayCallback object to let it know how things are going.
4 | *
5 | *
There is now an additional bonus: the DelayCallback object can use the delay(done, total)
6 | * function to (possibly) abort the process. If the user indicates he wants the process aborted,
7 | * delay(done, total) will return false.
8 | *
9 | * @author Gaurav Vaidya gaurav@ggvaidya.com
10 | */
11 |
12 | /*
13 | * TaxonDNA
14 | * Copyright (C) 2005 Gaurav Vaidya
15 | *
16 | * This program is free software; you can redistribute it and/or modify
17 | * it under the terms of the GNU General Public License as published by
18 | * the Free Software Foundation; either version 2 of the License, or
19 | * (at your option) any later version.
20 | *
21 | * This program is distributed in the hope that it will be useful,
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 | * GNU General Public License for more details.
25 | *
26 | * You should have received a copy of the GNU General Public License
27 | * along with this program; if not, write to the Free Software
28 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 | *
30 | */
31 |
32 | package com.ggvaidya.TaxonDNA.Common;
33 |
34 | public interface DelayCallback {
35 | /** This function is called when the delay begins. */
36 | void begin();
37 |
38 | /** This function is called when the delay ends. */
39 | void end();
40 |
41 | /**
42 | * This function is called during the delay.
43 | *
44 | * @param done number of steps which have been carried out
45 | * @param total number of steps which have to be done
46 | * @throws DelayAbortedException if the delay was interrupted (presumably by the user)
47 | */
48 | void delay(int done, int total) throws DelayAbortedException;
49 |
50 | /**
51 | * This func-err, method - can be called by the delaying component to indicate a *warning* which
52 | * isn't serious enough to stop the process, but the user should be informed. The DelayCallback
53 | * should inform the user after end() gets called.
54 | */
55 | void addWarning(String warning);
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/PairwiseDistance.java:
--------------------------------------------------------------------------------
1 | /**
2 | * PairwiseDistance is a single instance of a 'pairwise distance', comprising the distance itself,
3 | * as well as the two sequences which are that far apart. You should check out PairwiseDistances
4 | * (which is really just a sorted Vector of PairwiseDistance objects) to figure out what's really
5 | * going on.
6 | */
7 | /*
8 | TaxonDNA
9 | Copyright (C) Gaurav Vaidya, 2006
10 |
11 | This program is free software; you can redistribute it and/or modify
12 | it under the terms of the GNU General Public License as published by
13 | the Free Software Foundation; either version 2 of the License, or
14 | (at your option) any later version.
15 |
16 | This program is distributed in the hope that it will be useful,
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | GNU General Public License for more details.
20 |
21 | You should have received a copy of the GNU General Public License
22 | along with this program; if not, write to the Free Software
23 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 | */
25 |
26 | package com.ggvaidya.TaxonDNA.Common.DNA;
27 |
28 | public class PairwiseDistance implements Comparable {
29 | private double distance = -1;
30 |
31 | public double getDistance() {
32 | return distance;
33 | }
34 |
35 | private Sequence seqA = null;
36 |
37 | public Sequence getSequenceA() {
38 | return seqA;
39 | }
40 |
41 | private Sequence seqB = null;
42 |
43 | public Sequence getSequenceB() {
44 | return seqB;
45 | }
46 |
47 | public PairwiseDistance(Sequence a, Sequence b) {
48 | seqA = a;
49 | seqB = b;
50 |
51 | distance = seqA.getPairwise(seqB);
52 | }
53 |
54 | public boolean isMentioned(Sequence seq) {
55 | return (seq.equals(seqA) || seq.equals(seqB));
56 | }
57 |
58 | public int compareTo(Object o) {
59 | // we 'naturally' sort by distance as smallest first
60 | PairwiseDistance pd = (PairwiseDistance) o;
61 |
62 | return (int) Settings.makeLongFromDouble(getDistance() - pd.getDistance());
63 | }
64 |
65 | public String toString() {
66 | return super.toString()
67 | + ": "
68 | + getDistance()
69 | + " between "
70 | + getSequenceA()
71 | + " and "
72 | + getSequenceB();
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/UI/CloseableWindow.java:
--------------------------------------------------------------------------------
1 | /**
2 | * A Closeable Dialog wraps a normal dialog, adding code to close it when a windowClosing() event is
3 | * fired.
4 | */
5 | /*
6 | TaxonDNA
7 | Copyright (C) 2006 Gaurav Vaidya
8 |
9 | This program is free software; you can redistribute it and/or modify
10 | it under the terms of the GNU General Public License as published by
11 | the Free Software Foundation; either version 2 of the License, or
12 | (at your option) any later version.
13 |
14 | This program is distributed in the hope that it will be useful,
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | GNU General Public License for more details.
18 |
19 | You should have received a copy of the GNU General Public License
20 | along with this program; if not, write to the Free Software
21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 | */
23 | package com.ggvaidya.TaxonDNA.Common.UI;
24 |
25 | import java.awt.*;
26 | import java.awt.event.*;
27 |
28 | public class CloseableWindow implements WindowListener, KeyListener {
29 | private static CloseableWindow singleton = null;
30 |
31 | private CloseableWindow() {}
32 |
33 | private static CloseableWindow getInstance() {
34 | if (singleton == null) singleton = new CloseableWindow();
35 | return singleton;
36 | }
37 |
38 | /** Creates a default button named "OK". */
39 | public static Window wrap(Window wrap) {
40 | wrap.addWindowListener(CloseableWindow.getInstance());
41 | // wrap.addKeyListener(CloseableWindow.getInstance()); -- DOESN'T WORK!
42 | return wrap;
43 | }
44 |
45 | public void windowActivated(WindowEvent e) {}
46 |
47 | public void windowClosed(WindowEvent e) {}
48 |
49 | public void windowClosing(WindowEvent e) {
50 | Window w = (Window) e.getSource();
51 | w.setVisible(false);
52 | }
53 |
54 | public void windowDeactivated(WindowEvent e) {}
55 |
56 | public void windowDeiconified(WindowEvent e) {}
57 |
58 | public void windowIconified(WindowEvent e) {}
59 |
60 | public void windowOpened(WindowEvent e) {}
61 |
62 | public void keyPressed(KeyEvent e) {
63 | if (Window.class.isAssignableFrom(e.getSource().getClass())) {
64 | if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
65 | ((Window) e.getSource()).setVisible(false);
66 | }
67 | }
68 | }
69 |
70 | public void keyReleased(KeyEvent e) {}
71 |
72 | public void keyTyped(KeyEvent e) {}
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/Pearls.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Pearls. Because some of us wish we were coding in Perl.
3 | *
4 | *
(Note: this file was hacked together as coding continued, basically any time I pined for Perl.
5 | * The functions do not attempt to fully, or even partially, emulate their corresponding Perl
6 | * functions or actions. They only do as much as my program needs them to do.)
7 | *
8 | * @author Gaurav Vaidya gaurav@ggvaidya.com
9 | */
10 |
11 | /*
12 | * TaxonDNA
13 | * Copyright (C) 2007 Gaurav Vaidya
14 | *
15 | * This program is free software; you can redistribute it and/or modify
16 | * it under the terms of the GNU General Public License as published by
17 | * the Free Software Foundation; either version 2 of the License, or
18 | * (at your option) any later version.
19 | *
20 | * This program is distributed in the hope that it will be useful,
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 | * GNU General Public License for more details.
24 | *
25 | * You should have received a copy of the GNU General Public License
26 | * along with this program; if not, write to the Free Software
27 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 | *
29 | */
30 |
31 | package com.ggvaidya.TaxonDNA.Common;
32 |
33 | import java.util.*;
34 |
35 | public class Pearls {
36 | /**
37 | * 'Joins' a Collection into a String.
38 | *
39 | *
Analagous to join()
40 | */
41 | public static String join(String joiner, Collection coll) {
42 | StringBuffer buff = new StringBuffer();
43 |
44 | Iterator i = coll.iterator();
45 | while (i.hasNext()) {
46 | String str = i.next().toString();
47 | buff.append(str);
48 | if (i.hasNext()) buff.append(joiner);
49 | }
50 |
51 | return buff.toString();
52 | }
53 |
54 | /**
55 | * 'Joins' a Collection into a String. This function allowes you to denote both a 'before' and
56 | * an after'. For instance, repeat('A', @list, 'B') will give you A$list[0]BA@list[1]B...
57 | *
58 | *
It's the best I can do without continuations, I guess =/
59 | */
60 | public static String repeat(String before, Collection coll, String after) {
61 | StringBuffer buff = new StringBuffer();
62 |
63 | Iterator i = coll.iterator();
64 | while (i.hasNext()) {
65 | String str = i.next().toString();
66 |
67 | buff.append(before);
68 | buff.append(str);
69 | buff.append(after);
70 | }
71 |
72 | return buff.toString();
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/UI/UIExtension.java:
--------------------------------------------------------------------------------
1 | /**
2 | * An interface to allow extension of the SpeciesIdentifier UI. It lists out the basic structure
3 | * required of any object which wants to extend the UI. The getShortName() and getPanel() are the
4 | * only ones which actually need to *do* anything, although of course the others must be
5 | * implemented, atleast as stubs. They are intended for Future Use (if any can be dreamed up).
6 | *
7 | * @author Gaurav Vaidya, gaurav@ggvaidya.com
8 | */
9 |
10 | /*
11 | TaxonDNA
12 | Copyright (C) 2005 Gaurav Vaidya
13 |
14 | This program is free software; you can redistribute it and/or modify
15 | it under the terms of the GNU General Public License as published by
16 | the Free Software Foundation; either version 2 of the License, or
17 | (at your option) any later version.
18 |
19 | This program is distributed in the hope that it will be useful,
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | GNU General Public License for more details.
23 |
24 | You should have received a copy of the GNU General Public License
25 | along with this program; if not, write to the Free Software
26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 | */
28 | package com.ggvaidya.TaxonDNA.Common.UI;
29 |
30 | import java.awt.*;
31 |
32 | public interface UIExtension {
33 | /**
34 | * Returns the short name of this extension. This name will be used to identify the extension in
35 | * menus, forms and the like.
36 | */
37 | String getShortName();
38 |
39 | /**
40 | * Returns a one-paragraph description of this extension. This will be used to let the user know
41 | * what this extension is supposed to do.
42 | */
43 | String getDescription();
44 |
45 | /**
46 | * Used to notify the extension that the data has changed. Check back with the owner to see
47 | * what's going on.
48 | */
49 | void dataChanged();
50 |
51 | /**
52 | * If the application has a menu for "commands", and you would like to add anything to this
53 | * menu, just add it to the commandMenu. Don't end with a separator, we'll handle that. If you
54 | * have a lot of commands, you're welcome to add a PopupMenu instead.
55 | *
56 | * @return true, if a separator needs to be added after whatever you've done. SpeciesIdentifier
57 | * won't add a separator if you're the last item in the menu.
58 | */
59 | boolean addCommandsToMenu(Menu commandMenu);
60 |
61 | /**
62 | * Returns the 'Panel' of this extension. If you return null, there will be no Panel - i.e.,
63 | * your extension will be present but not visible.
64 | */
65 | Panel getPanel();
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/Others/UUID.java:
--------------------------------------------------------------------------------
1 | /**
2 | * A class representing a UUID [1]. Okay, this is a hack. Read my lips: H-A-C-K. I'm only doing this
3 | * because it'll HELP (not STOP) programs from screwing up. UUID engines are way too complex for me
4 | * to try and handcode one right now just to get AlignmentHelper working. Plus, hopefully, the WORSE
5 | * thing that can happen is a collision (two UUIDs are identical), which should be handled by
6 | * another part of the program - and ideally, that BARFS. So it's all good :).
7 | *
8 | * @author Gaurav Vaidya, gaurav@ggvaidya.com
9 | */
10 | /*
11 | TaxonDNA
12 | Copyright (C) 2005 Gaurav Vaidya
13 |
14 | This program is free software; you can redistribute it and/or modify
15 | it under the terms of the GNU General Public License as published by
16 | the Free Software Foundation; either version 2 of the License, or
17 | (at your option) any later version.
18 |
19 | This program is distributed in the hope that it will be useful,
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | GNU General Public License for more details.
23 |
24 | You should have received a copy of the GNU General Public License
25 | along with this program; if not, write to the Free Software
26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 | */
28 |
29 | package com.ggvaidya.TaxonDNA.Common.Others;
30 |
31 | public class UUID {
32 | private static long lastAllocated = 0;
33 | private static int lastSequenceNo = 0;
34 | private long myTimestamp = 0;
35 | private int mySequenceNo = 0;
36 | private static Object lock = new Object();
37 |
38 | public UUID() {
39 | synchronized (lock) {
40 | myTimestamp = System.currentTimeMillis();
41 | mySequenceNo = 1;
42 |
43 | if (myTimestamp == lastAllocated) mySequenceNo = lastSequenceNo + 1;
44 |
45 | lastAllocated = myTimestamp;
46 | lastSequenceNo = mySequenceNo;
47 | }
48 | // System.err.println("Unique ID allocated: " + toString());
49 | }
50 |
51 | // equals()? Only if you're another UUID, mate
52 | public boolean equals(Object o) {
53 | return equals((UUID) o);
54 | }
55 |
56 | // equals()? Only if the UIDs match, mate
57 | public boolean equals(UUID uid2) {
58 | return uid2.getUUID().equals(getUUID());
59 | }
60 |
61 | // if you're "one of us" ... you get to know this
62 | // otherwise, please, just use equals(Object) and be happy with it ...
63 | protected String getUUID() {
64 | return myTimestamp + "_" + mySequenceNo;
65 | }
66 |
67 | // guaranteed to be unique
68 | public String toString() {
69 | return getUUID();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/formats/BaseFormatHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Basic implementation of a FormatHandler. Mostly here to simplify the FormatListener
3 | * implementation just a little :).
4 | */
5 |
6 | /*
7 | TaxonDNA
8 | Copyright (C) 2005-07 Gaurav Vaidya
9 |
10 | his program is free software; you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation; either version 2 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program; if not, write to the Free Software
22 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 | */
24 |
25 | package com.ggvaidya.TaxonDNA.Common.DNA.formats;
26 |
27 | import com.ggvaidya.TaxonDNA.Common.*;
28 | import com.ggvaidya.TaxonDNA.Common.DNA.*;
29 | import java.io.*;
30 | import java.util.*;
31 |
32 | public class BaseFormatHandler implements FormatHandler {
33 | protected Vector formatListeners = new Vector();
34 |
35 | public String getShortName() {
36 | return "Base Format Handler";
37 | }
38 |
39 | public String getExtension() {
40 | return "txt";
41 | }
42 |
43 | public String getFullName() {
44 | return "Base for all Format Handlers in TaxonDNA";
45 | }
46 |
47 | public SequenceList readFile(File file, DelayCallback delay)
48 | throws IOException, SequenceException, FormatException, DelayAbortedException {
49 | return null;
50 | }
51 |
52 | public void appendFromFile(SequenceList appendTo, File fileFrom, DelayCallback delay)
53 | throws IOException, SequenceException, FormatException, DelayAbortedException {}
54 |
55 | public void writeFile(File file, SequenceList set, DelayCallback delay)
56 | throws IOException, DelayAbortedException {}
57 |
58 | public boolean mightBe(File file) {
59 | return false;
60 | }
61 |
62 | public void addFormatListener(FormatListener listener) {
63 | if (!formatListeners.contains(listener)) formatListeners.add(listener);
64 | }
65 |
66 | public void removeFormatListener(FormatListener listener) {
67 | formatListeners.remove(listener);
68 | }
69 |
70 | public void fireEvent(FormatHandlerEvent evt) throws FormatException {
71 | Iterator i = formatListeners.iterator();
72 | while (i.hasNext()) {
73 | FormatListener fl = (FormatListener) i.next();
74 |
75 | if (fl.eventOccured(evt)) return; // event consumed! get out of here!
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.ant.freeform
4 |
5 |
6 | TaxonDNA
7 |
8 |
9 |
10 | TaxonDNA
11 |
12 |
13 |
14 |
15 | .
16 | UTF-8
17 |
18 |
19 |
20 | java
21 | src
22 | MacRoman
23 |
24 |
25 |
26 |
27 | SequenceMatrix.app
28 |
29 |
30 | clean
31 |
32 |
33 | javadocs
34 |
35 |
36 | run_dclusters
37 |
38 |
39 | clean
40 | SequenceMatrix.app
41 |
42 |
43 |
44 |
45 |
46 |
47 | src
48 |
49 |
50 | build.xml
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | src
66 | 1.5
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/formats/Interleaver.java:
--------------------------------------------------------------------------------
1 | /** The Interleaver helps you DNA.formats classes to output interleaved sequences. */
2 |
3 | /*
4 | TaxonDNA
5 | Copyright (C) 2006 Gaurav Vaidya
6 |
7 | This program is free software; you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation; either version 2 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program; if not, write to the Free Software
19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 | */
21 |
22 | package com.ggvaidya.TaxonDNA.Common.DNA.formats;
23 |
24 | import com.ggvaidya.TaxonDNA.Common.DNA.*;
25 | import java.util.*;
26 |
27 | public class Interleaver {
28 | private Hashtable seqs = new Hashtable(); // String(name) -> Sequence
29 | private Vector sequenceNames = new Vector(); // sequenceNames, in the order they were added
30 |
31 | public Interleaver() {}
32 |
33 | /**
34 | * Get the sequence with the specified name. This is the sequence 'to date': so please don't ask
35 | * us before you're all done giving us the data.
36 | */
37 | public Sequence getSequence(String name) {
38 | return (Sequence) seqs.get(name);
39 | }
40 |
41 | /** Set OR REPLACE the sequence with the specified name. */
42 | public void setSequence(String name, Sequence seq) {
43 | if (seqs.get(name) == null) sequenceNames.add(name);
44 | seqs.put(name, seq);
45 | }
46 |
47 | /**
48 | * Append OR CREATE a sequence with the specified name. Note that this is not tested.
49 | *
50 | * @throws SequenceException if there is an error in the combined Sequence
51 | */
52 | public void appendSequence(String name, String sequence) throws SequenceException {
53 | appendSequence(name, BaseSequence.createSequence(name, sequence));
54 | }
55 |
56 | public void appendSequence(String name, Sequence seq) {
57 | if (seqs.get(name) == null) {
58 | sequenceNames.add(name);
59 | seqs.put(name, seq);
60 | } else {
61 | // append it onto the currently existing 'Sequence'
62 | Sequence our_seq = (Sequence) seqs.get(name);
63 | our_seq = our_seq.concatSequence(seq);
64 | seqs.put(name, our_seq);
65 | }
66 | }
67 |
68 | /**
69 | * Returns an iterator to a list of species names. You can call getSequence() to get the
70 | * Sequences themselves.
71 | */
72 | public Iterator getSequenceNamesIterator() {
73 | return sequenceNames.iterator();
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/GenBankExplorer/Preferences.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Preferences is a common store for preferences. 'Preferences' preferences are stored into the
3 | * java.util.prefs store, and are thus persistant across sessions (heh heh - ain't I the software
4 | * engineer!). Everybody can check with us through a generic preferences system
5 | * (getPreference/setPreference), as well as to check some of the variables we ourselves maintain.
6 | */
7 |
8 | /*
9 | *
10 | * GenBankExplorer
11 | * Copyright (C) 2007 Gaurav Vaidya
12 | *
13 | * This program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program; if not, write to the Free Software
25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 | *
27 | */
28 |
29 | package com.ggvaidya.TaxonDNA.GenBankExplorer;
30 |
31 | import com.ggvaidya.TaxonDNA.Common.UI.*;
32 |
33 | public class Preferences {
34 | private GenBankExplorer matrix = null; // the GenBankExplorer object
35 |
36 | /** Constructor. Sets up the UI (on the dialog object, which isn't madeVisible just yet) and */
37 | public Preferences(GenBankExplorer matrix) {
38 | // set up the GenBankExplorer
39 | this.matrix = matrix;
40 | }
41 |
42 | //
43 | // the general Preference functions
44 | //
45 | /** Sets the preference specified */
46 | public void setPreference(String key, String value) {
47 | java.util.prefs.Preferences.userNodeForPackage(getClass()).put(key, value);
48 | }
49 |
50 | /**
51 | * Returns the preference specified
52 | *
53 | * @param def default value for this key
54 | */
55 | public String getPreference(String key, String def) {
56 | return java.util.prefs.Preferences.userNodeForPackage(getClass()).get(key, def);
57 | }
58 |
59 | /** Sets the preference specified (as int) */
60 | public void setPreference(String key, int value) {
61 | java.util.prefs.Preferences.userNodeForPackage(getClass()).putInt(key, value);
62 | }
63 |
64 | /**
65 | * Returns the preference specified (as int)
66 | *
67 | * @param def default value for this key
68 | */
69 | public int getPreference(String key, int def) {
70 | return java.util.prefs.Preferences.userNodeForPackage(getClass()).getInt(key, def);
71 | }
72 |
73 | public void beginNewSession() {
74 | // clear all session-based variables
75 | // right now, this is only PREF_NOT_SET_YET.
76 | MessageBox.resetSession(); // reset all MB_YESNOTOALL
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/UI/DefaultButton.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Creates a default button: a button which will kill the dialog box it's in, and will try to
3 | * override the DialogBox's keyboard handling to pick up any 'Enter's. Note that having two
4 | * DefaultButtons in a Dialog or Frame is undefined, but I'm guessing the first one -
5 | * chronologically - will fire.
6 | */
7 | package com.ggvaidya.TaxonDNA.Common.UI;
8 |
9 | import java.awt.*;
10 | import java.awt.event.*;
11 |
12 | public class DefaultButton extends Button implements ActionListener, KeyListener {
13 | private Window parentWindow = null;
14 | private boolean wasClicked = false;
15 |
16 | /**
17 | * Makes the specified button 'default' - clicking on it will close the window it's in, and
18 | * pressing 'Enter' in that window will cause us to fire, closing it.
19 | */
20 | public void makeButtonDefault(Window parent) {
21 | if (parent == null) // can't do this unless we've got a parent!
22 | throw new IllegalArgumentException(
23 | "Cannot make default button: parent window specified as 'null'!");
24 |
25 | // now, we need to store the Window we found ON the Button
26 | parentWindow = (Window) parent;
27 |
28 | // and register this class with all the handlers we need
29 | addActionListener(this);
30 | parentWindow.addKeyListener(this);
31 | }
32 |
33 | /** Creates a default button named "OK". */
34 | public DefaultButton(Window parent) {
35 | super("OK");
36 | makeButtonDefault(parent);
37 | }
38 |
39 | /** Creates a default button with the specified label */
40 | public DefaultButton(Window parent, String label) {
41 | super(label);
42 | makeButtonDefault(parent);
43 | }
44 |
45 | /**
46 | * Sometimes, you need to know whether the window closed because of the dialog window closing,
47 | * or whether this button was clicked to close. Returns true if it was this button.
48 | */
49 | public boolean wasClicked() {
50 | return wasClicked;
51 | }
52 |
53 | /**
54 | * This action listener listens for clicks, and if recieved, calls setVisible(false) on the
55 | * parent window.
56 | */
57 | public void actionPerformed(ActionEvent e) {
58 | if (e.getSource().equals(this)) {
59 | wasClicked = true;
60 |
61 | // that's us!
62 | if (parentWindow != null) {
63 | parentWindow.setVisible(false);
64 | parentWindow.dispose();
65 | }
66 | }
67 | }
68 |
69 | /**
70 | * This KeyListener listens for 'Enter', and generates a click on this button if it is detected.
71 | */
72 | public void keyTyped(KeyEvent e) {
73 | if (e.getKeyCode() == KeyEvent.VK_ENTER) {
74 | processActionEvent(
75 | new ActionEvent(this, ActionEvent.ACTION_PERFORMED, getActionCommand()));
76 | }
77 | }
78 |
79 | /** KeyListener detritus. */
80 | public void keyReleased(KeyEvent e) {}
81 |
82 | /** KeyListener detritus. */
83 | public void keyPressed(KeyEvent e) {}
84 | }
85 |
--------------------------------------------------------------------------------
/params.json:
--------------------------------------------------------------------------------
1 | {"name":"Sequence Matrix","tagline":"Assemble multigene/multitaxon phylogenetic datasets easily","body":"Sequence Matrix allows you to easily concatenate gene datasets. A spreadsheet-like interface displays what you've assembled so far; TNT, Nexus, FASTA and Mega files can be dragged into the application to add them. Your entire dataset can be exported as TNT or Nexus files.\r\n\r\nTo find out more, please see our [introductory screencast](http://www.youtube.com/watch?v=Adwr-CZdNOM) of Sequence Matrix on YouTube. We've also [made available a presentation on Sequence Matrix](http://www.slideshare.net/mrvaidya/sequence-matrix-gene-concatenation-made-easy-4797559) (delivered to the Hennig XXVIII conference in June 2009) and [the paper we wrote](http://dx.doi.org/10.1111/j.1096-0031.2010.00329.x) describing Sequence Matrix in Cladistics. \r\n\r\n# For users of MacOS X 10.10 (Yosemite)\r\n\r\nThe latest MacOS X version of Sequence Matrix available on this website will not work on MacOS X 10.10 or above. I've created a release of Sequence Matrix 1.7.8 using [packr](https://github.com/libgdx/packr) which appears to work on newer releases of MacOS X which is [available for download](https://docs.google.com/uc?id=0B_F6LJAWh8sieHVlMjAxWW9qVnM&export=download) from Google Docs.\r\n\r\nIf you get an \"unidentified developer\" error, please right-click on the file and select \"Open\": you should get the some error, but with an \"Open\" button that allows you to bypass it. Alternatively, you can change your security settings: go to System Preferences on your Mac, click on \"Security & Privacy\" and go to the \"General\" tab. If you set \"All apps downloaded from:\" to \"Anywhere\", Sequence Matrix should run without any problem.\r\n\r\n# Testimonials\r\n\r\nHere are some reviews of Sequence Matrix we've spotted around the internet.\r\n\r\n * \"Thanks so much. This software has saved me many hours of tedious work.\" -- [evanmelstad](http://www.youtube.com/user/evanmelstad) on [YouTube](http://www.youtube.com/comment?lc=bOaM8sE6UvMNa2ZilLgH45-Uti1e3fwDMQ2dXEtzNXQ).\r\n\r\n * \"It is a real pain combining matrices from different loci, particularly when you have taxa represented in one matrix and not in another. I’ve usually done this by hand and it gets tedious. I recently stumbled across a Java tool that makes this process quite simple: SequenceMatrix.\" -- [The Glor Lab](http://lacertilia.com/?p=1420), University of Rochester. \r\n\r\n \"... the 12 individual gene alignments were concatenated using the software SequenceMatrix v1.7.6 (Vaidya et al., 2011) to create a master alignment of 10,836 bp total, equivalent to roughly 65% of the mtDNA genome.\" -- ''[Pleistocene diversification of living squirrel monkeys (Saimiri spp.) inferred from complete mitochondrial genome sequences](http://dx.doi.org/10.1016/j.ympev.2011.03.025)'' by Kenneth L. Chioua, Luca Pozzia, Jessica W. Lynch Alfaroc and Anthony Di Fiore. \r\n\r\n# Problems? Let us know!\r\n\r\nIf you find any bugs in this or any other release, please [report them to us](https://github.com/gaurav/taxondna/issues)! The source code for this project is available [on GitHub](http://github.com/gaurav/taxondna).","google":"UA-17621072-5","note":"Don't delete this file! It's used internally to help with page regeneration."}
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/SequenceMatrix/Commands.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Commands have commands to access SequenceMatrix functionality through commands. For now, this is
3 | * entirely for the command line command system, but maybe an Undo/Redo system could be built up
4 | * about this.
5 | */
6 |
7 | /*
8 | *
9 | * SequenceMatrix
10 | * Copyright (C) 2009 Gaurav Vaidya
11 | *
12 | * This program is free software; you can redistribute it and/or modify
13 | * it under the terms of the GNU General Public License as published by
14 | * the Free Software Foundation; either version 2 of the License, or
15 | * (at your option) any later version.
16 | *
17 | * This program is distributed in the hope that it will be useful,
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | * GNU General Public License for more details.
21 | *
22 | * You should have received a copy of the GNU General Public License
23 | * along with this program; if not, write to the Free Software
24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 | *
26 | */
27 |
28 | package com.ggvaidya.TaxonDNA.SequenceMatrix;
29 |
30 | import com.ggvaidya.TaxonDNA.Common.*;
31 | import java.io.*;
32 | import java.util.*;
33 |
34 | public class Commands {
35 | private static SequenceMatrix matrix = null; // the SequenceMatrix object
36 |
37 | /** Executes a set of commands coming off the command line */
38 | public static void executeCmdLine(SequenceMatrix input_matrix, List commands) {
39 | matrix = input_matrix; // Set this up.
40 |
41 | Vector cmds = new Vector(commands);
42 |
43 | // Now, we should split this into words, and "recognize" commands
44 | // by the leading '--'. These commands are presented to an
45 | // execute(List) method, which takes the command and all necessary
46 | // arguments, and then returns control.
47 | while (cmds.size() > 0) {
48 | String cmd = (String) cmds.remove(0);
49 |
50 | if (cmd.substring(0, 2).equals("--")) {
51 | // A command!
52 | cmd = cmd.substring(2);
53 |
54 | execute(cmd, cmds);
55 | } else {
56 | output(cmd + " is not a valid command.");
57 | }
58 | }
59 | }
60 |
61 | /** Executes a simple command, possibly getting other arguments off a queue. */
62 | public static void execute(String cmd, List arguments) {
63 | cmd = cmd.toLowerCase();
64 |
65 | if (cmd.equals("version")) {
66 | output("This is SequenceMatrix v" + Versions.getTaxonDNA());
67 | } else if (cmd.equals("add")) {
68 | String filename = (String) arguments.remove(0);
69 |
70 | matrix.getFileManager().addFile(new File(filename));
71 | } else if (cmd.equals("quit") || cmd.equals("exit")) {
72 | System.exit(0);
73 | } else {
74 | output("Unable to understand command: " + cmd);
75 | }
76 | }
77 |
78 | /** How to provide output. */
79 | public static void output(String s) {
80 | System.err.println(s);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/docs/stylesheets/github-light.css:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2014 GitHub Inc.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 |
16 | */
17 |
18 | .pl-c /* comment */ {
19 | color: #969896;
20 | }
21 |
22 | .pl-c1 /* constant, markup.raw, meta.diff.header, meta.module-reference, meta.property-name, support, support.constant, support.variable, variable.other.constant */,
23 | .pl-s .pl-v /* string variable */ {
24 | color: #0086b3;
25 | }
26 |
27 | .pl-e /* entity */,
28 | .pl-en /* entity.name */ {
29 | color: #795da3;
30 | }
31 |
32 | .pl-s .pl-s1 /* string source */,
33 | .pl-smi /* storage.modifier.import, storage.modifier.package, storage.type.java, variable.other, variable.parameter.function */ {
34 | color: #333;
35 | }
36 |
37 | .pl-ent /* entity.name.tag */ {
38 | color: #63a35c;
39 | }
40 |
41 | .pl-k /* keyword, storage, storage.type */ {
42 | color: #a71d5d;
43 | }
44 |
45 | .pl-pds /* punctuation.definition.string, string.regexp.character-class */,
46 | .pl-s /* string */,
47 | .pl-s .pl-pse .pl-s1 /* string punctuation.section.embedded source */,
48 | .pl-sr /* string.regexp */,
49 | .pl-sr .pl-cce /* string.regexp constant.character.escape */,
50 | .pl-sr .pl-sra /* string.regexp string.regexp.arbitrary-repitition */,
51 | .pl-sr .pl-sre /* string.regexp source.ruby.embedded */ {
52 | color: #183691;
53 | }
54 |
55 | .pl-v /* variable */ {
56 | color: #ed6a43;
57 | }
58 |
59 | .pl-id /* invalid.deprecated */ {
60 | color: #b52a1d;
61 | }
62 |
63 | .pl-ii /* invalid.illegal */ {
64 | background-color: #b52a1d;
65 | color: #f8f8f8;
66 | }
67 |
68 | .pl-sr .pl-cce /* string.regexp constant.character.escape */ {
69 | color: #63a35c;
70 | font-weight: bold;
71 | }
72 |
73 | .pl-ml /* markup.list */ {
74 | color: #693a17;
75 | }
76 |
77 | .pl-mh /* markup.heading */,
78 | .pl-mh .pl-en /* markup.heading entity.name */,
79 | .pl-ms /* meta.separator */ {
80 | color: #1d3e81;
81 | font-weight: bold;
82 | }
83 |
84 | .pl-mq /* markup.quote */ {
85 | color: #008080;
86 | }
87 |
88 | .pl-mi /* markup.italic */ {
89 | color: #333;
90 | font-style: italic;
91 | }
92 |
93 | .pl-mb /* markup.bold */ {
94 | color: #333;
95 | font-weight: bold;
96 | }
97 |
98 | .pl-md /* markup.deleted, meta.diff.header.from-file */ {
99 | background-color: #ffecec;
100 | color: #bd2c00;
101 | }
102 |
103 | .pl-mi1 /* markup.inserted, meta.diff.header.to-file */ {
104 | background-color: #eaffea;
105 | color: #55a532;
106 | }
107 |
108 | .pl-mdr /* meta.diff.range */ {
109 | color: #795da3;
110 | font-weight: bold;
111 | }
112 |
113 | .pl-mo /* meta.output */ {
114 | color: #1d3e81;
115 | }
116 |
117 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/formats/FormatHandlerEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * A FormatHandlerEvent stores information about the state of the FormatHandler when the event was
3 | * fired - which file it was processing, which line it was on, which formatHandler object was being
4 | * used - as well as what actually happened.
5 | *
6 | *
This could get complicated, and I desperately wish there was an easier way to handle this
7 | * madness. Any ideas? Anybody?
8 | */
9 |
10 | /*
11 | TaxonDNA
12 | Copyright (C) 2005, 2006 Gaurav Vaidya
13 |
14 | This program is free software; you can redistribute it and/or modify
15 | it under the terms of the GNU General Public License as published by
16 | the Free Software Foundation; either version 2 of the License, or
17 | (at your option) any later version.
18 |
19 | This program is distributed in the hope that it will be useful,
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | GNU General Public License for more details.
23 |
24 | You should have received a copy of the GNU General Public License
25 | along with this program; if not, write to the Free Software
26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 | */
28 |
29 | package com.ggvaidya.TaxonDNA.Common.DNA.formats;
30 |
31 | import com.ggvaidya.TaxonDNA.Common.DNA.*;
32 | import java.io.*;
33 |
34 | public class FormatHandlerEvent {
35 | /** There was no event */
36 | public static final int NO_EVENT = 0;
37 |
38 | /**
39 | * A file-wide character set was detected; the FormatHandler would like to inform you of the
40 | * same.
41 | */
42 | public static final int CHARACTER_SET_FOUND = 1;
43 |
44 | // environment info
45 | private File f = null;
46 |
47 | public File getFile() {
48 | return f;
49 | }
50 |
51 | private FormatHandler fh = null;
52 |
53 | public FormatHandler getFormatHandler() {
54 | return fh;
55 | }
56 |
57 | private SequenceList sl = null;
58 |
59 | public SequenceList getSequenceList() {
60 | return sl;
61 | }
62 |
63 | private int id = NO_EVENT;
64 |
65 | public int getId() {
66 | return id;
67 | }
68 |
69 | // event specific info
70 | public String name = null;
71 | public Sequence sequence = null;
72 | public int from = 0;
73 | public int to = 0;
74 |
75 | /** Standard constructor. You can specify 'null' to any of these. */
76 | public FormatHandlerEvent(File f, FormatHandler fh, SequenceList sl) {
77 | this.f = f;
78 | this.fh = fh;
79 | this.sl = sl;
80 | }
81 |
82 | /**
83 | * Specify a CHARACTER_SET_FOUND event. Note the following about CHARACTER_SET_FOUND events: 1.
84 | * There may be multiple character sets. 2. Each character set might cover multiple areas. Each
85 | * area will be called in ONCE and SEPARATELY! Hence, YOU (and you alone) are responsible for
86 | * figuring out: 1. which areas are redundant (used in two or more features already) 2. which
87 | * areas are called out multiple times. 3. any other issue you might have with this system.
88 | *
89 | *
It's quite new and quite rocky yet. Apologies.
90 | */
91 | public FormatHandlerEvent makeCharacterSetFoundEvent(String called, int from, int to) {
92 | FormatHandlerEvent evt = new FormatHandlerEvent(f, fh, sl);
93 | evt.id = CHARACTER_SET_FOUND;
94 | evt.name = called;
95 | evt.from = from;
96 | evt.to = to;
97 |
98 | return evt;
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/SpeciesIdentifier/CommandLine.java:
--------------------------------------------------------------------------------
1 | /**
2 | * SpeciesIdentifier's command line interface. Handles *every* straight off the command line. The
3 | * ultimate dream is to allow SpeciesIdentifier to be used off the command line for certain quick
4 | * operations (conversion). It would also be a very fast way of implementing a testing harness
5 | * around the currently existing code.
6 | *
7 | *
How it works: if SpeciesIdentifier detects a 'command line' (of any sort), it hands control
8 | * over to CommandLine.processCommandLine(String[] args). CommandLine can then call
9 | * SpeciesIdentifier to set up a normal SpeciesIdentifier object, create multiple SpeciesIdentifier
10 | * objects, or directly interface with the SpeciesIdentifier.* objects to carry out the analyses.
11 | *
12 | *
When eventually I get to finishing up this module, it might help to look up Java's guidelines
13 | * on POSIX-compliant command line arguments at:
14 | * http://java.sun.com/docs/books/tutorial/essential/attributes/_posix.html They're short and
15 | * succinct, etc.
16 | *
17 | * @author Gaurav Vaidya, gaurav@ggvaidya.com
18 | */
19 |
20 | /*
21 | TaxonDNA
22 | Copyright (C) Gaurav Vaidya, 2006
23 |
24 | This program is free software; you can redistribute it and/or modify
25 | it under the terms of the GNU General Public License as published by
26 | the Free Software Foundation; either version 2 of the License, or
27 | (at your option) any later version.
28 |
29 | This program is distributed in the hope that it will be useful,
30 | but WITHOUT ANY WARRANTY; without even the implied warranty of
31 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 | GNU General Public License for more details.
33 |
34 | You should have received a copy of the GNU General Public License
35 | along with this program; if not, write to the Free Software
36 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
37 | */
38 |
39 | package com.ggvaidya.TaxonDNA.SpeciesIdentifier;
40 |
41 | import java.io.*;
42 | import java.util.*;
43 |
44 | public class CommandLine {
45 | LinkedList files = new LinkedList(); // files specified to be opened (List of Files)
46 | LinkedList unknown = new LinkedList(); // unknown arguments (List of Strings)
47 |
48 | /**
49 | * Creates a CommandLine object, by parsing the command line. The execute function then 'makes
50 | * sense of it all'
51 | */
52 | public CommandLine(String[] args) {
53 | for (int x = 0; x < args.length; x++) {
54 | String arg = args[x];
55 |
56 | // if we don't know what it is, assume it's a file
57 | File f = new File(arg);
58 | if (f.exists()) {
59 | files.add(f);
60 | continue;
61 | }
62 |
63 | // no? then it's unknown!
64 | unknown.add(arg);
65 | }
66 | }
67 |
68 | /** Uses the information gathered from parsing the command line to do stuff. */
69 | public void execute() {
70 | boolean inGuiMode = true;
71 |
72 | // Are we in 'command line' mode or 'GUI' mode?
73 | // For now, there's only GUI mode
74 |
75 | if (inGuiMode) {
76 | // warn the user about unknown options
77 |
78 | // are there any files specified?
79 | if (files.isEmpty()) new SpeciesIdentifier();
80 | else {
81 | Iterator i = files.iterator();
82 |
83 | while (i.hasNext()) {
84 | SpeciesIdentifier td = new SpeciesIdentifier();
85 | td.loadFile((File) i.next(), null);
86 | }
87 | }
88 | }
89 | }
90 |
91 | public static void processCommandLine(String[] args) {
92 | CommandLine cl = new CommandLine(args);
93 | cl.execute();
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/Release/SequenceMatrix/Sample files/Scathophagidae_Concatenation_check_batch.nex:
--------------------------------------------------------------------------------
1 | #NEXUS
2 | [INSTRUCTIONS:
3 | 1. Execute batch file from file folder with the input gene files and the concatenated matrix
4 | 2. Confirm the 'data set resets' when PAUP* requests them
5 | 2. For each gene PAUP* will determine the number constant, variable, and parsimony-informative characters of the data in the input file and the same data within the concatenated matrix
6 | 3. These numbers will be logged to one log file for each ribosomal gene and three files for protein-encoding genes with codon information
7 | 4. Open the log files and compare the character statistics; they should be the same for the data in the input file and within the concatenated matrix
8 | 5. Batch file can be modified for any concatenation job through search-and-replace of the gene names]
9 |
10 | set WarnRedef=no;
11 | set autoclose;
12 | log file=SCATH12S.log start replace;
13 | execute Scathophagidae.nex;
14 | exclude all; include SCATH12S;
15 | cstatus;
16 | execute SCATH12S.nex;
17 | cstatus;
18 | log stop;
19 |
20 | log file=SCATH16S.log start replace;
21 | execute Scathophagidae.nex;
22 | excl all; incl SCATH16S;
23 | cstatus;
24 | execute SCATH16S.nex;
25 | cstatus;
26 | log stop;
27 |
28 | log file=SCATH28Sac.log start replace;
29 | execute Scathophagidae.nex;
30 | excl all; incl SCATH28Sac;
31 | cstatus;
32 | execute SCATH28Sac.nex;
33 | cstatus;
34 | log stop;
35 |
36 | log file=SCATHCOI-1st.log start replace;
37 | execute Scathophagidae.nex;
38 | excl all; incl SCATHCOI; excl pos2; excl pos3;
39 | cstatus;
40 | execute SCATHCOI.nex;
41 | excl all; incl pos1;
42 | cstatus;
43 | log stop;
44 |
45 | log file=SCATHCOI-2st.log start replace;
46 | execute Scathophagidae.nex;
47 | excl all; incl SCATHCOI; excl pos1; excl pos3;
48 | cstatus;
49 | execute SCATHCOI.nex;
50 | excl all; incl pos2;
51 | cstatus;
52 | log stop;
53 |
54 | log file=SCATHCOI-3rd.log start replace;
55 | execute Scathophagidae.nex;
56 | excl all; incl SCATHCOI; excl pos1; excl pos2;
57 | cstatus;
58 | execute SCATHCOI.nex;
59 | excl all; incl pos3;
60 | cstatus;
61 | log stop;
62 |
63 | log file=SCATHEF1A-1st.log start replace;
64 | execute Scathophagidae.nex;
65 | excl all; incl SCATHEF1A; excl pos2; excl pos3;
66 | cstatus;
67 | execute SCATHEF1A.nex;
68 | excl all; incl pos1;
69 | cstatus;
70 | log stop;
71 |
72 | log file=SCATHEF1A-2st.log start replace;
73 | execute Scathophagidae.nex;
74 | excl all; incl SCATHEF1A; excl pos1; excl pos3;
75 | cstatus;
76 | execute SCATHEF1A.nex;
77 | excl all; incl pos2;
78 | cstatus;
79 | log stop;
80 |
81 | log file=SCATHEF1A-3rd.log start replace;
82 | execute Scathophagidae.nex;
83 | excl all; incl SCATHEF1A; excl pos1; excl pos2;
84 | cstatus;
85 | execute SCATHEF1A.nex;
86 | excl all; incl pos3;
87 | cstatus;
88 | log stop;
89 |
90 | log file=SCATHCYTB-1st.log start replace;
91 | execute Scathophagidae.nex;
92 | excl all; incl SCATHCYTB; excl pos2; excl pos3;
93 | cstatus;
94 | execute SCATHCYTB.nex;
95 | excl all; incl pos1;
96 | cstatus;
97 | log stop;
98 |
99 | log file=SCATHCYTB-2st.log start replace;
100 | execute Scathophagidae.nex;
101 | excl all; incl SCATHCYTB; excl pos1; excl pos3;
102 | cstatus;
103 | execute SCATHCYTB.nex;
104 | excl all; incl pos2;
105 | cstatus;
106 | log stop;
107 |
108 | log file=SCATHCYTB-3rd.log start replace;
109 | execute Scathophagidae.nex;
110 | excl all; incl SCATHCYTB; excl pos1; excl pos2;
111 | cstatus;
112 | execute SCATHCYTB.nex;
113 | excl all; incl pos3;
114 | cstatus;
115 | log stop;
116 |
117 | log file=SCATHrpol-1st.log start replace;
118 | execute Scathophagidae.nex;
119 | excl all; incl SCATHrpol; excl pos2; excl pos3;
120 | cstatus;
121 | execute SCATHrpol.nex;
122 | excl all; incl pos1;
123 | cstatus;
124 | log stop;
125 |
126 | log file=SCATHrpol-2st.log start replace;
127 | execute Scathophagidae.nex;
128 | excl all; incl SCATHrpol; excl pos1; excl pos3;
129 | cstatus;
130 | execute SCATHrpol.nex;
131 | excl all; incl pos2;
132 | cstatus;
133 | log stop;
134 |
135 | log file=SCATHrpol-3rd.log start replace;
136 | execute Scathophagidae.nex;
137 | excl all; incl SCATHrpol; excl pos1; excl pos2;
138 | cstatus;
139 | execute SCATHrpol.nex;
140 | excl all; incl pos3;
141 | cstatus;
142 | log stop;
143 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/UI/ProgressBar.java:
--------------------------------------------------------------------------------
1 | /**
2 | * A ProgressBar is a canvas which gradually fills up when the changeIndicator() is called. It may
3 | * have a String (text) written across it as well.
4 | *
5 | *
As a hack, we use the inactiveCaption/activeCaption contrast to power our bar. As the two must
6 | * contrast sharply, it might look ugly (probably not) but will be very flexible across OSs. On the
7 | * other hand, we're assuming both colours are dark, so we can write the text ("Please wait ...
8 | * (5%)") in white over them.
9 | *
10 | * @author Gaurav Vaidya, gaurav@ggvaidya.com
11 | */
12 |
13 | /*
14 | TaxonDNA
15 | Copyright (C) 2005 Gaurav Vaidya
16 |
17 | This program is free software; you can redistribute it and/or modify
18 | it under the terms of the GNU General Public License as published by
19 | the Free Software Foundation; either version 2 of the License, or
20 | (at your option) any later version.
21 |
22 | This program is distributed in the hope that it will be useful,
23 | but WITHOUT ANY WARRANTY; without even the implied warranty of
24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 | GNU General Public License for more details.
26 |
27 | You should have received a copy of the GNU General Public License
28 | along with this program; if not, write to the Free Software
29 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 | */
31 |
32 | package com.ggvaidya.TaxonDNA.Common.UI;
33 |
34 | import com.ggvaidya.TaxonDNA.Common.*;
35 | import java.awt.*;
36 |
37 | public class ProgressBar extends Canvas implements DelayCallback {
38 | private int done = 0;
39 | private int total = 100;
40 | private String text = "";
41 |
42 | /** Creates a ProgressBar with no text. */
43 | public ProgressBar() {
44 | setBackground(SystemColor.inactiveCaption);
45 | setSize(20, 20);
46 | }
47 |
48 | /** Creates a ProgressBar with a specified text. */
49 | public ProgressBar(String text) {
50 | this();
51 | this.text = text;
52 | }
53 |
54 | /**
55 | * Changes the "indicator" of the bar. The change should be continually increasing, or the bar
56 | * will stay "stuck" at the higher point until the values catch up again.
57 | */
58 | public void changeIndicator(int done, int total) {
59 | this.done = done;
60 | this.total = total;
61 |
62 | invalidate();
63 | if (isShowing()) {
64 | paint(getGraphics());
65 | }
66 | }
67 |
68 | public void setText(String text) {
69 | this.text = text;
70 | }
71 |
72 | /** Paints the progress bar */
73 | public void paint(Graphics g) {
74 | int width = (int) ((float) getWidth() * ((float) done / total));
75 |
76 | g.setColor(SystemColor.inactiveCaption);
77 | g.fillRect(width, 0, getWidth(), getHeight());
78 | g.setColor(SystemColor.activeCaption);
79 | g.fillRect(0, 0, width, getHeight());
80 |
81 | if (!text.isEmpty()) {
82 | String display = text + " (" + (int) ((float) done / total * 100) + "%)";
83 |
84 | int stringWidth = g.getFontMetrics().stringWidth(display);
85 | int stringX = (getWidth() - stringWidth) / 2;
86 | int stringY =
87 | g.getFontMetrics().getHeight()
88 | + (getHeight() - g.getFontMetrics().getHeight()) / 4;
89 |
90 | // g.setColor(SystemColor.activeCaption);
91 | // g.setXORMode(SystemColor.inactiveCaption);
92 | g.setColor(Color.WHITE);
93 | g.drawString(display, stringX, stringY);
94 | }
95 | }
96 |
97 | // Delay callback methods
98 | //
99 | public void begin() {
100 | setText("Please wait ...");
101 | }
102 |
103 | public void delay(int done, int total) {
104 | changeIndicator(done, total);
105 | }
106 |
107 | public void end() {
108 | setText("All done!");
109 | changeIndicator(100, 100);
110 | }
111 |
112 | public void addWarning(String x) {
113 | throw new RuntimeException("ProgressBars cannot indicate warnings to users, sorry!");
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Releases/*
2 |
3 | # Ignore .DS_Store Mac-specific preview file.
4 | **/.DS_Store
5 |
6 | # Added Eclipse.gitignore from https://github.com/github/gitignore/blob/218a941be92679ce67d0484547e3e142b2f5f6f0/Global/Eclipse.gitignore
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .settings/
16 | .loadpath
17 | .recommenders
18 |
19 | # External tool builders
20 | .externalToolBuilders/
21 |
22 | # Locally stored "Eclipse launch configurations"
23 | *.launch
24 |
25 | # PyDev specific (Python IDE for Eclipse)
26 | *.pydevproject
27 |
28 | # CDT-specific (C/C++ Development Tooling)
29 | .cproject
30 |
31 | # CDT- autotools
32 | .autotools
33 |
34 | # Java annotation processor (APT)
35 | .factorypath
36 |
37 | # PDT-specific (PHP Development Tools)
38 | .buildpath
39 |
40 | # sbteclipse plugin
41 | .target
42 |
43 | # Tern plugin
44 | .tern-project
45 |
46 | # TeXlipse plugin
47 | .texlipse
48 |
49 | # STS (Spring Tool Suite)
50 | .springBeans
51 |
52 | # Code Recommenders
53 | .recommenders/
54 |
55 | # Annotation Processing
56 | .apt_generated/
57 | .apt_generated_test/
58 |
59 | # Scala IDE specific (Scala & Java development for Eclipse)
60 | .cache-main
61 | .scala_dependencies
62 | .worksheet
63 |
64 | # Uncomment this line if you wish to ignore the project description file.
65 | # Typically, this file would be tracked if it contains build/dependency configurations:
66 | #.project
67 |
68 | # Added JetBrains.gitignore from https://github.com/github/gitignore/blob/218a941be92679ce67d0484547e3e142b2f5f6f0/Global/JetBrains.gitignore
69 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
70 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
71 |
72 | # User-specific stuff
73 | .idea/**/workspace.xml
74 | .idea/**/tasks.xml
75 | .idea/**/usage.statistics.xml
76 | .idea/**/dictionaries
77 | .idea/**/shelf
78 |
79 | # Generated files
80 | .idea/**/contentModel.xml
81 |
82 | # Sensitive or high-churn files
83 | .idea/**/dataSources/
84 | .idea/**/dataSources.ids
85 | .idea/**/dataSources.local.xml
86 | .idea/**/sqlDataSources.xml
87 | .idea/**/dynamic.xml
88 | .idea/**/uiDesigner.xml
89 | .idea/**/dbnavigator.xml
90 |
91 | # Gradle
92 | .idea/**/gradle.xml
93 | .idea/**/libraries
94 |
95 | # Gradle and Maven with auto-import
96 | # When using Gradle or Maven with auto-import, you should exclude module files,
97 | # since they will be recreated, and may cause churn. Uncomment if using
98 | # auto-import.
99 | # .idea/artifacts
100 | # .idea/compiler.xml
101 | # .idea/jarRepositories.xml
102 | # .idea/modules.xml
103 | # .idea/*.iml
104 | # .idea/modules
105 | # *.iml
106 | # *.ipr
107 |
108 | # CMake
109 | cmake-build-*/
110 |
111 | # Mongo Explorer plugin
112 | .idea/**/mongoSettings.xml
113 |
114 | # File-based project format
115 | *.iws
116 |
117 | # IntelliJ
118 | out/
119 |
120 | # mpeltonen/sbt-idea plugin
121 | .idea_modules/
122 |
123 | # JIRA plugin
124 | atlassian-ide-plugin.xml
125 |
126 | # Cursive Clojure plugin
127 | .idea/replstate.xml
128 |
129 | # Crashlytics plugin (for Android Studio and IntelliJ)
130 | com_crashlytics_export_strings.xml
131 | crashlytics.properties
132 | crashlytics-build.properties
133 | fabric.properties
134 |
135 | # Editor-based Rest Client
136 | .idea/httpRequests
137 |
138 | # Android studio 3.1+ serialized cache file
139 | .idea/caches/build_file_checksums.ser
140 |
141 | # Added Maven.gitignore from https://github.com/github/gitignore/blob/218a941be92679ce67d0484547e3e142b2f5f6f0/Maven.gitignore
142 | target/
143 | pom.xml.tag
144 | pom.xml.releaseBackup
145 | pom.xml.versionsBackup
146 | pom.xml.next
147 | release.properties
148 | dependency-reduced-pom.xml
149 | buildNumber.properties
150 | .mvn/timing.properties
151 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar
152 | .mvn/wrapper/maven-wrapper.jar
153 |
154 | # Added Java.gitignore from https://github.com/github/gitignore/blob/218a941be92679ce67d0484547e3e142b2f5f6f0/Java.gitignore
155 | # Compiled class file
156 | *.class
157 |
158 | # Log file
159 | *.log
160 |
161 | # BlueJ files
162 | *.ctxt
163 |
164 | # Mobile Tools for Java (J2ME)
165 | .mtj.tmp/
166 |
167 | # Package Files #
168 | *.jar
169 | *.war
170 | *.nar
171 | *.ear
172 | *.zip
173 | *.tar.gz
174 | *.rar
175 |
176 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
177 | hs_err_pid*
178 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/SpeciesDetail.java:
--------------------------------------------------------------------------------
1 | /**
2 | * A SpeciesDetail object holds information about one particular species in a SpeciesDetails map.
3 | *
4 | * @author Gaurav Vaidya, gaurav@ggvaidya.com
5 | */
6 |
7 | /*
8 | TaxonDNA
9 | Copyright (C) 2006, 2010 Gaurav Vaidya
10 |
11 | This program is free software; you can redistribute it and/or modify
12 | it under the terms of the GNU General Public License as published by
13 | the Free Software Foundation; either version 2 of the License, or
14 | (at your option) any later version.
15 |
16 | This program is distributed in the hope that it will be useful,
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | GNU General Public License for more details.
20 |
21 | You should have received a copy of the GNU General Public License
22 | along with this program; if not, write to the Free Software
23 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 | */
25 |
26 | package com.ggvaidya.TaxonDNA.Common.DNA;
27 |
28 | import java.util.*;
29 |
30 | public class SpeciesDetail {
31 | private String species_name;
32 | private int length_longestSequence = 0;
33 | private ArrayList sequences = new ArrayList();
34 |
35 | /** You can't create a SpeciesDetail unless you, err, provide the details. */
36 | private SpeciesDetail() {}
37 |
38 | /** Our most useful constructor. */
39 | public SpeciesDetail(String species_name) {
40 | this.species_name = species_name;
41 | }
42 |
43 | /** Add a sequence to this "species". */
44 | public void add(Sequence seq) {
45 | if (!seq.getSpeciesName().equals(species_name))
46 | throw new RuntimeException(
47 | "Tried to add " + seq + " to a species detail of " + species_name);
48 |
49 | // Process all the numbers.
50 | if (seq.getLength() > length_longestSequence) {
51 | length_longestSequence = seq.getLength();
52 | }
53 |
54 | // Add this sequence to our list.
55 | sequences.add(seq);
56 | }
57 |
58 | /**
59 | * @return A list of sequences associated with this species detail.
60 | */
61 | public List getSequences() {
62 | return (List) sequences;
63 | }
64 |
65 | /**
66 | * @return The number of sequences in this species detail.
67 | */
68 | public int getSequencesCount() {
69 | return sequences.size();
70 | }
71 |
72 | /**
73 | * Determine how many sequences have a "valid match", i.e. a conspecific which has less than the
74 | * minimum overlap.
75 | *
76 | * @return The number of such sequences.
77 | */
78 | public int getSequencesWithValidConspecificsCount() {
79 | int valid_matches = 0;
80 |
81 | for (Sequence seq : sequences) {
82 | for (Sequence seq_inner : sequences) {
83 | if (seq_inner == seq) continue;
84 |
85 | if (seq.hasMinOverlap(seq_inner)) {
86 | valid_matches++;
87 | break; // Will break out of inner, but not outer, loop.
88 | }
89 | }
90 | }
91 |
92 | return valid_matches;
93 | }
94 |
95 | /**
96 | * Determine how many sequences *don't* have a valid match, i.e. a conspecific which has less
97 | * than the minimum overlap.
98 | *
99 | * @return The number of such sequences.
100 | */
101 | public int getSequencesWithoutValidConspecificsCount() {
102 | return getSequencesCount() - getSequencesWithValidConspecificsCount();
103 | }
104 |
105 | /**
106 | * @return The length of the longest sequence in this SpeciesDetail.
107 | */
108 | public int getLongestSequenceLength() {
109 | return length_longestSequence;
110 | }
111 |
112 | /**
113 | * @return a list of GI numbers as a concatenated string.
114 | */
115 | public String getGINumbersAsString() {
116 | StringBuffer buff = new StringBuffer();
117 |
118 | for (Sequence seq : sequences) {
119 | if (seq.getGI() != null) buff.append("gi|" + seq.getGI() + "| ");
120 | else buff.append("(Sequence with unknown GI number) ");
121 | }
122 |
123 | return buff.toString();
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/Testing.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Testing tests the DNA segment. You can either call Testing.testAll() (or another 'testing'
3 | * function) or you can run the class directly (we've got our own main()).
4 | */
5 |
6 | /*
7 | TaxonDNA
8 | Copyright (C) 2007 Gaurav Vaidya
9 |
10 | This program is free software; you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation; either version 2 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program; if not, write to the Free Software
22 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 | */
24 |
25 | package com.ggvaidya.TaxonDNA.Common.DNA;
26 |
27 | import java.util.*;
28 |
29 | public class Testing {
30 | public static void main(String args[]) {
31 | println("Starting testing of TaxonDNA.DNA ...");
32 | Testing.testAll();
33 | println("Testing ended.");
34 | }
35 |
36 | public static void testTransScoring() {
37 | println("Testing pairwise distances calculated by transversions ...");
38 |
39 | try {
40 | char[] purines = "AGR".toCharArray();
41 | char[] pyrimidines = "TCY".toCharArray();
42 | char[] neither = "KMSWBDHVN".toCharArray();
43 |
44 | println("Testing purines ...");
45 | for (int x = 0; x < purines.length; x++) {
46 | if (!Sequence.isPurine(purines[x]))
47 | println("ERROR: purine " + purines[x] + " is not counted as a purine!");
48 | if (Sequence.isPyrimidine(purines[x]))
49 | println("ERROR: purine " + purines[x] + " is counted as a pyrimidine!");
50 | }
51 |
52 | println("Testing pyrimidines ...");
53 | for (int x = 0; x < pyrimidines.length; x++) {
54 | if (!Sequence.isPyrimidine(pyrimidines[x]))
55 | println(
56 | "ERROR: pyrimidine "
57 | + pyrimidines[x]
58 | + " is not counted as a pyrimidine!");
59 | if (Sequence.isPurine(pyrimidines[x]))
60 | println("ERROR: pyrimidine " + pyrimidines[x] + " is counted as a purines!");
61 | }
62 |
63 | println("Testing neither ...");
64 | for (int x = 0; x < neither.length; x++) {
65 | if (Sequence.isPyrimidine(neither[x]))
66 | println("ERROR: NPNP " + neither[x] + " is counted as a pyrimidine!");
67 | if (Sequence.isPurine(neither[x]))
68 | println("ERROR: NPNP " + neither[x] + " is counted as a purines!");
69 | }
70 |
71 | println("Testing distances ...");
72 |
73 | Sequence.setPairwiseDistanceMethod(Sequence.PDM_TRANS_ONLY);
74 | Sequence.setMinOverlap(1);
75 |
76 | Sequence seq_a = new Sequence("T1", "--ATCCCTGGTA");
77 | Sequence seq_b = new Sequence("T2", "ACCGCCCT--CG");
78 |
79 | if (seq_a.getPairwise(seq_b) != 0.2)
80 | println(
81 | "Incorrect: ought to be 0.2, reported as "
82 | + seq_a.getPairwise(seq_b)
83 | + "; #trans = "
84 | + seq_a.countTransversions(seq_b)
85 | + "; overlap = "
86 | + seq_a.getSharedLength(seq_b));
87 | else println("Simple test successful!");
88 |
89 | } catch (Exception e) {
90 | println("ERROR: " + e);
91 | }
92 |
93 | println("Transversion testing done!");
94 | }
95 |
96 | public static void testSequence() {
97 | int old_method = Sequence.getPairwiseDistanceMethod();
98 | int old_overlap = Sequence.getMinOverlap();
99 | testTransScoring();
100 | Sequence.setPairwiseDistanceMethod(old_method);
101 | Sequence.setMinOverlap(old_overlap);
102 | }
103 |
104 | public static void testAll() {
105 | testSequence();
106 | }
107 |
108 | public static void println(String s) {
109 | System.err.println(new Date() + ": " + s);
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/Settings.java:
--------------------------------------------------------------------------------
1 | /**
2 | * DNA.Settings controls settings for all DNA classes. They check back here for constants, controls,
3 | * and optimizations.
4 | *
5 | *
Just to clarify: Sequence has a certain, fixed format for dealing with Sequences (using '-'
6 | * for gaps, for instance). That is how it works. Deal with it.
7 | *
8 | *
Settings controls the (very little) stuff in DNA which can be played around with. It should be
9 | * noted that values are *read from* here, so all values which might be affected ought to be
10 | * recalculated in between changing settings.
11 | *
12 | *
Somewhere, somehow, people who actually know Java are laughing at me ...
13 | */
14 |
15 | /*
16 | TaxonDNA
17 | Copyright (C) 2005 Gaurav Vaidya
18 |
19 | This program is free software; you can redistribute it and/or modify
20 | it under the terms of the GNU General Public License as published by
21 | the Free Software Foundation; either version 2 of the License, or
22 | (at your option) any later version.
23 |
24 | This program is distributed in the hope that it will be useful,
25 | but WITHOUT ANY WARRANTY; without even the implied warranty of
26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 | GNU General Public License for more details.
28 |
29 | You should have received a copy of the GNU General Public License
30 | along with this program; if not, write to the Free Software
31 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 | */
33 |
34 | package com.ggvaidya.TaxonDNA.Common.DNA;
35 |
36 | public class Settings {
37 | /**
38 | * What proportion of the total memory the pairwise distance cache is allowed to use until. (Ha!
39 | * Okay, seriously: the fraction of used memory to total memory at which the cache flushes
40 | * itself)
41 | */
42 | public static double PairwiseCacheMemoryUsageLimit = 0.9;
43 |
44 | /*
45 | * What values should the DNA.* functions be accurate to?
46 | * We'll be accurate to 1/accurateTo.
47 | */
48 | private static int accurateTo = 100000;
49 |
50 | /** Returns the value we are accurate to. */
51 | public static double getAccurateTo() {
52 | return 1 / (double) accurateTo;
53 | }
54 |
55 | /** Sets the value we should be accurate to. e.g. 0.0001 */
56 | public static void setAccurateTo(double d) {
57 | accurateTo = (int) (1 / d);
58 | }
59 |
60 | /** Sets the number of digits we should be accurate to. * e.g. 4 for 0.0001 */
61 | public static void setAccurateToDigits(int digits) {
62 | accurateTo = (int) Math.pow(10, digits);
63 | }
64 |
65 | /**
66 | * Converts the specified double to an int at the necessary level of accuracy. Think of it as a
67 | * log-transform. You can use makeDoubleFromLong() to convert it back.
68 | */
69 | public static long makeLongFromDouble(double d) {
70 | return (long) (d * accurateTo);
71 | }
72 |
73 | /**
74 | * Converts the specified int (from makeLongFromDouble) to an int at the necessary level of
75 | * accuracy.
76 | *
77 | * @see #makeLongFromDouble(double)
78 | */
79 | public static double makeDoubleFromLong(long i) {
80 | return i / (double) accurateTo;
81 | }
82 |
83 | /** Percentage, rounded off to two decimal places. */
84 | public static double percentage(double x, double y) {
85 | if (y == 0) return 0; // x% of nothing is zero percent
86 | return (double) ((long) (roundOff(x / y) * 100 * 100)) / 100;
87 | }
88 |
89 | /** Rounds off a value to its nearest double which is accurate. */
90 | public static double roundOff(double d) {
91 | return makeDoubleFromLong(makeLongFromDouble(d));
92 | }
93 |
94 | /** Compares two doubles at the necessary level of accuracy. */
95 | public static boolean identical(double d1, double d2) {
96 | return (makeLongFromDouble(d1) == makeLongFromDouble(d2));
97 | }
98 |
99 | /** Get the minimum overlap necessary to make a comparison. */
100 | public static int getMinimumOverlap() {
101 | return Sequence.getMinOverlap();
102 | }
103 |
104 | /** Set the minimum overlap necessary to make a comparison. */
105 | public static void setMinimumOverlap(int minOverlap) {
106 | Sequence.setMinOverlap(minOverlap);
107 | }
108 |
109 | /**
110 | * Returns true if ambiguous bases are allowed. If not, we'll convert ambiguous bases to 'N'
111 | * during comparisons.
112 | */
113 | public static boolean areAmbiguousBasesAllowed() {
114 | return Sequence.areAmbiguousBasesAllowed();
115 | }
116 |
117 | /**
118 | * Set whether ambiguous bases are allowed. If not, we'll convert ambiguous bases to 'N' during
119 | * comparisons.
120 | */
121 | public static void setAmbiguousBasesAllowed(boolean allowed) {
122 | Sequence.ambiguousBasesAllowed(allowed);
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TaxonDNA
2 |
3 | [](https://doi.org/10.5281/zenodo.14994608)
4 |
5 | ## Citing TaxonDNA
6 |
7 | Two publications cover the two main TaxonDNA tools:
8 |
9 | * For SpeciesIdentifier, please cite: Meier, R., Kwong, S., Vaidya, G., Ng, Peter K. L. (2006)
10 | *DNA Barcoding and Taxonomy in Diptera: a Tale of High Intraspecific Variability and Low Identification Success*.
11 | Systematic Biology **55**: 715--728. [doi:10.1080/10635150600969864](https://doi.org/10.1080/10635150600969864).
12 | * For SequenceMatrix, please cite: Vaidya, G., Lohman, D.J., Meier, R. (2011) *SequenceMatrix: concatenation software
13 | for the fast assembly of multi-gene datasets with character set and codon information*. Cladistics 27: 171--180.
14 | [doi:10.1111/j.1096-0031.2010.00329.x](https://doi.org/10.1111/j.1096-0031.2010.00329.x).
15 |
16 | For other software, please cite this repository via Zenodo:
17 |
18 | * Vaidya (2025) *TaxonDNA*. GitHub: https://github.com/gaurav/taxondna. [doi:10.5281/zenodo.14994608](https://doi.org/10.5281/zenodo.14994608)
19 |
20 | ## System requirements
21 |
22 | TaxonDNA is written entirely in Java, with its interface written using
23 | either Java AWT or Swing. Its only requirement is a standard Java VM -
24 | except that since TaxonDNA 1.6 we've given up supporting Java 1.4, so
25 | you'll need to have atleast Java 1.5 since then.
26 |
27 | There are a [long list of bugs](http://code.google.com/p/taxondna/issues/list),
28 | some of which prevent TaxonDNA from working well on multiple platforms. Note
29 | particularly UI-related issues: some UI elements only work on particular
30 | platforms, although we try to work around them as well as we can.
31 |
32 | ## Individual tools
33 |
34 | TaxonDNA consists of three tools - Species Identifier [2], SequenceMatrix,
35 | and GenBank Explorer (still in beta). JNLP files for the first two
36 | are available in this repository (but you'll have to get someone to
37 | the latest JAR files to Sourceforge), as well as MS-DOS Batch files,
38 | if you prefer those. You should be able to get GBX working by compiling it
39 | from source:
40 |
41 | ```shell
42 | $ mvn package
43 | $ java -jar target/TaxonDNA-1.10-SNAPSHOT-SpeciesIdentifier.jar
44 | ```
45 |
46 | ## Building software
47 |
48 | TaxonDNA uses Maven for packaging. You can build all the outputs by running:
49 |
50 | ```shell
51 | $ mvn package
52 | ```
53 |
54 | This will create both JAR files and ZIP files for distribution in the `target/`
55 | directory.
56 |
57 | ## Tests
58 |
59 | We do not currently have tests. But someday we will!
60 |
61 | ## Running TaxonDNA
62 |
63 | TaxonDNA uses an unfortunately a large amount of memory per sequence.
64 | It can handle larger files fairly well, but by default, Java
65 | applications are limited to 64mb. You will need to use the '-Xmx'
66 | option to increase your memory usage. The easiest way to do this is,
67 | at the command line, to enter:
68 |
69 | ```shell
70 | $ java -Xmx1024M -jar TaxonDNA.jar
71 | ```
72 |
73 | You might also have to adjust the value of 1024 megabytes depending
74 | on the size of your dataset and on the memory available to your
75 | computer. Java will refuse to run if the Xmx value specified is too
76 | large. Also, if TaxonDNA.jar is not in the directory specified, you
77 | might need to enter the complete path to TaxonDNA, as so:
78 |
79 | ```shell
80 | > java -Xmx1024M -jar C:\TaxonDNA\TaxonDNA.jar
81 | ```
82 |
83 | If the program runs out of memory while running, it will appear to
84 | "hang" and become completely unresponsive. There is at present no
85 | way to recover from this state. You'll want to increase your memory
86 | setting using "-Xmx" as shown above.
87 |
88 | Please note that trying to load a sequences file larger than the
89 | memory size specified (i.e. 1024 mb in the above example) will also
90 | result in the program hanging. We have tested this program with a
91 | file of 2,185 sequences with 2,664 base pairs, and it has been known
92 | to work on datasets upto 8,000 sequences long. Please let us know if
93 | memory size is an issue for you, and we will try to incorporate
94 | workarounds in future versions.
95 |
96 | ## File formats
97 |
98 | This program can handle input in FASTA, MEGA, Nexus and TNT formats.
99 | GenBank support is provided through the GenBankExplorer. FASTA
100 | is our oldest supported format, and most of the tools are designed
101 | to accept sequences from NCBI GanBank (exported as FASTA) as input.
102 | It attempts to guess the species name from the FASTA title string,
103 | and considers hyphens ('-') as gaps, and question marks ('?') as
104 | missing data (incidently, if you use a very different gap/missing
105 | syntax, you could use Nexus as an intermediate format, since it
106 | supports defining your own gap/missing data specifier.
107 |
108 | ## Contacting us
109 |
110 | You can get in touch with the developers in our
111 | [GitHub repository](https://github.com/gaurav/taxondna), specifically
112 | by [opening an issue](https://github.com/gaurav/taxondna/issues/new)
113 | if something doesn't work correctly. You can also e-mail me
114 | at gaurav at ggvaidya dot com.
115 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/GenBankExplorer/LociDisplayMode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The LociDisplayMode displays locuses (loci), in the order they are present in the file. It's a
3 | * simple system so we can figure out how Trees work and so on, and get our interfaces in order
4 | * somewhat before moving onto more interesting things (like the long-mythical FeatureDisplayMode).
5 | */
6 |
7 | /*
8 | *
9 | * GenBankExplorer
10 | * Copyright (C) 2007 Gaurav Vaidya
11 | *
12 | * This program is free software; you can redistribute it and/or modify
13 | * it under the terms of the GNU General Public License as published by
14 | * the Free Software Foundation; either version 2 of the License, or
15 | * (at your option) any later version.
16 | *
17 | * This program is distributed in the hope that it will be useful,
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | * GNU General Public License for more details.
21 | *
22 | * You should have received a copy of the GNU General Public License
23 | * along with this program; if not, write to the Free Software
24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 | *
26 | */
27 |
28 | package com.ggvaidya.TaxonDNA.GenBankExplorer;
29 |
30 | import com.ggvaidya.TaxonDNA.Common.DNA.*;
31 | import java.util.*;
32 | import javax.swing.tree.*;
33 |
34 | public class LociDisplayMode extends DisplayMode {
35 | public LociDisplayMode(ViewManager man) {
36 | super(man);
37 | }
38 |
39 | public void setGenBankFile(GenBankFile genBankFile) {
40 | super.setGenBankFile(genBankFile);
41 |
42 | if (genBankFile != null) {
43 | viewManager.setFileText(
44 | "Current file: "
45 | + genBankFile.getFile().getAbsolutePath()
46 | + "\nNumber of loci in file: "
47 | + genBankFile.getLocusCount());
48 | } else {
49 | viewManager.setFileText("No file loaded.");
50 | }
51 | }
52 |
53 | public Object getRoot() {
54 | if (genBankFile == null) return "No file loaded";
55 |
56 | return "Current file (" + genBankFile.getFile().getAbsolutePath() + ")";
57 | }
58 |
59 | protected java.util.List getSubnodes(Object node) {
60 | if (genBankFile == null) return null;
61 |
62 | if (node.equals(getRoot())) {
63 | return genBankFile.getLoci();
64 | }
65 |
66 | int index = getIndexOfChild(getRoot(), node);
67 | if (index == -1)
68 | // means that we're probably looking for a sub-sub-node
69 | ;
70 | else {
71 | GenBankFile.Locus l = genBankFile.getLocus(index);
72 | if (l != null) {
73 | return l.getSections();
74 | }
75 | }
76 |
77 | return null;
78 | }
79 |
80 | public void pathSelected(TreePath p) {
81 | Object obj = p.getLastPathComponent();
82 | Class cls = obj.getClass();
83 |
84 | if (cls.equals(String.class)) {
85 | viewManager.setSelectionText("");
86 |
87 | } else if (cls.equals(GenBankFile.Locus.class)) {
88 | GenBankFile.Locus l = (GenBankFile.Locus) obj;
89 |
90 | StringBuffer buff = new StringBuffer();
91 | Iterator i_sec = l.getSections().iterator();
92 | while (i_sec.hasNext()) {
93 | GenBankFile.Section sec = (GenBankFile.Section) i_sec.next();
94 |
95 | buff.append(sec.getName() + ": " + sec.entry() + "\n");
96 | }
97 |
98 | viewManager.setSelectionText("Currently selected: locus " + l.toString() + "\n" + buff);
99 |
100 | } else if (GenBankFile.Section.class.isAssignableFrom(cls)) {
101 | GenBankFile.Section sec = (GenBankFile.Section) obj;
102 |
103 | String additionalText = "";
104 |
105 | if (GenBankFile.OriginSection.class.isAssignableFrom(cls)) {
106 | GenBankFile.OriginSection ori = (GenBankFile.OriginSection) obj;
107 | Sequence seq = null;
108 |
109 | try {
110 | seq = ori.getSequence();
111 | additionalText = "Sequence:\n" + seq.getSequenceWrapped(70);
112 |
113 | } catch (SequenceException e) {
114 | additionalText =
115 | "Sequence: Could not be extracted.\n"
116 | + "The following error occured while parsing sequence: "
117 | + e.getMessage();
118 | }
119 | }
120 |
121 | viewManager.setSelectionText(
122 | "Currently selected: section "
123 | + sec.getName()
124 | + " of locus "
125 | + sec.getLocus()
126 | + "\nValue: "
127 | + sec.entry()
128 | + "\n"
129 | + additionalText);
130 | }
131 | }
132 | }
133 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/FromToPair.java:
--------------------------------------------------------------------------------
1 | package com.ggvaidya.TaxonDNA.Common.DNA;
2 |
3 | /**
4 | * A special datatype storing coordinates within a sequence. At the moment, this is a pretty simple
5 | * thing; you'll need outside information to figure out what it means or where it's actually point
6 | * to.
7 | *
8 | *
Most important note: FromToPairs must ALWAYS be one-based. Zero-based FTPs are pure evil. This
9 | * makes very little sense, except that Sequence.getSubsequence uses 1-based indexes, and I am NOT
10 | * modifying that method, since it is very very old and probably in use all over the place.
11 | */
12 | public class FromToPair implements Comparable {
13 | public int from;
14 | public int to;
15 |
16 | public FromToPair(int from, int to) {
17 | if (from <= 0 || to <= 0)
18 | throw new RuntimeException(
19 | "FromTo of " + from + " to " + to + " invalid: less than or equal to zero!");
20 |
21 | if (to < from)
22 | throw new RuntimeException(
23 | "FromTo of " + from + " to " + to + " invalid: incorrect order!");
24 |
25 | this.from = from;
26 | this.to = to;
27 | }
28 |
29 | public FromToPair(FromToPair ftp) {
30 | this.from = ftp.from;
31 | this.to = ftp.to;
32 | }
33 |
34 | public int compareTo(Object o) {
35 | FromToPair ftp = (FromToPair) o;
36 |
37 | return (this.from - ftp.from);
38 | }
39 |
40 | public String toString() {
41 | if (from == to) return from + ""; // String convert on the fly.
42 | else return from + " to " + to;
43 | }
44 |
45 | /**
46 | * * Checks for overlap between us and another FromToPair.
47 | *
48 | * @param ftp The FTP to compare against
49 | * @return True if there is even a single digit of overlap, false otherwise.
50 | */
51 | public boolean overlaps(FromToPair ftp) {
52 | return
53 | // Check whether ftp.from intersects with us.
54 | ((ftp.from >= from) && (ftp.from <= to))
55 | ||
56 | // Check whether ftp.to intersects with us.
57 | ((ftp.to >= from) && (ftp.to <= to));
58 | }
59 |
60 | /**
61 | * * Checks for overlap, but assumes both FTPs move in threes. (i.e. they were marked with \3s).
62 | * Note that there is at present no way for this code to confirm that both FTPs move in threes:
63 | * please make sure they do before calling this method.
64 | *
65 | * @param ftp The FTP to compare against.
66 | * @return True if there is any overlap, false otherwise.
67 | */
68 | public boolean overlapsMovesInThrees(FromToPair ftp) {
69 | // All of this is meaningless with real overlap.
70 | // So:
71 | if (!this.overlaps(ftp)) return false;
72 |
73 | // There can be no possible overlap unless ftp.from % 3
74 | // and self.from % 3 are not identical. For the sake of
75 | // convenience, let's call this a "track"
76 | if ((this.from % 3) != (ftp.from % 3)) {
77 | System.err.println(
78 | "No comparison necessary between /3s loci "
79 | + this.from
80 | + " and "
81 | + ftp.from
82 | + ": separate tracks.");
83 |
84 | return false;
85 | }
86 | int track = this.from % 3;
87 |
88 | // So they're on the same track. To do the comparison now:
89 | // 1. We round both this.to and ftp.to to the last position which
90 | // is on the same track as self.from and ftp.from. Thus, both
91 | // ftp.to and this.to are valid locations. For want of a name,
92 | // we'll call this "rounding" the FTPs.
93 | FromToPair rounded_us = new FromToPair(this);
94 | FromToPair rounded_ftp = new FromToPair(ftp);
95 |
96 | // Round us.
97 | rounded_us.to = rounded_us.to - (rounded_us.to - rounded_us.from) % 3;
98 |
99 | if (rounded_us.to % 3 != track)
100 | throw new RuntimeException(
101 | "Algorithm fails: our 'to' rounded from "
102 | + this.to
103 | + " to "
104 | + rounded_us.to
105 | + " is not on track "
106 | + track
107 | + " from "
108 | + rounded_us.from);
109 |
110 | // Round ftp.
111 | rounded_ftp.to = rounded_ftp.to - (rounded_ftp.to - rounded_ftp.from) % 3;
112 |
113 | if (rounded_ftp.to % 3 != track)
114 | throw new RuntimeException(
115 | "Algorithm fails: their 'to' rounded from "
116 | + ftp.to
117 | + " to "
118 | + rounded_ftp.to
119 | + " is not on track "
120 | + track
121 | + " from "
122 | + rounded_ftp.from);
123 |
124 | // 2. Finally, everything is normalized; we just need to check for
125 | // any overlaps between the two ftps.
126 | System.err.println("Rounded from: " + rounded_us + " to: " + rounded_ftp + ", comparing.");
127 |
128 | return rounded_us.overlaps(rounded_ftp);
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/formats/FormatHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * A file format handler from DNA.formats. Each format handler is tied in to different file formats
3 | * - there would be one for FASTA files, one for Mega files, etc. You can interact with that code
4 | * using five methods:
5 | *
6 | *
String getShortName(): returns the short name of the format String getExtension(): the default
7 | * extension for this format. Should be three letters (just in case). String getLongName(): returns
8 | * the long name of the format void readFile(): reads a file, and appends it onto a SequenceList
9 | * void writeFile(): writes a SequenceList into the specific file boolean mightBe(): checks the file
10 | * signature and syntax to see if it might possibly belong to this format. This should be relatively
11 | * fast: we'll be running through the entire list, looking for matches.
12 | *
13 | *
This is fairly low level, and so you'll find long lists of exceptions so that people can
14 | * figure out what's going on. If you want a simple way of loading a file, look at SequenceList.
15 | */
16 |
17 | /*
18 | TaxonDNA
19 | Copyright (C) 2005, 2006 Gaurav Vaidya
20 |
21 | This program is free software; you can redistribute it and/or modify
22 | it under the terms of the GNU General Public License as published by
23 | the Free Software Foundation; either version 2 of the License, or
24 | (at your option) any later version.
25 |
26 | This program is distributed in the hope that it will be useful,
27 | but WITHOUT ANY WARRANTY; without even the implied warranty of
28 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 | GNU General Public License for more details.
30 |
31 | You should have received a copy of the GNU General Public License
32 | along with this program; if not, write to the Free Software
33 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 | */
35 |
36 | package com.ggvaidya.TaxonDNA.Common.DNA.formats;
37 |
38 | import com.ggvaidya.TaxonDNA.Common.*;
39 | import com.ggvaidya.TaxonDNA.Common.DNA.*;
40 | import java.io.*;
41 |
42 | public interface FormatHandler {
43 | /**
44 | * Returns the short name of this file format. E.g. "NEXUS", "MEGA", or "FASTA". Think about
45 | * whether you could put it into a sentence as "This is the ___ file format."
46 | */
47 | String getShortName();
48 |
49 | /** Returns the extension (ideally lowercase, no fullstops) for this kind of file. */
50 | String getExtension();
51 |
52 | /**
53 | * Returns the full name of this file format handler. E.g. "Nexus file format v2 and below". You
54 | * ought to put in something about what versions of the software you support. But not too long:
55 | * think about whether you could display it in a list.
56 | */
57 | String getFullName();
58 |
59 | /**
60 | * Read this file into the specified SequenceList. This will read all the files straight into
61 | * this sequence list, in the correct order.
62 | *
63 | * @throws IOException if there was an error doing I/O
64 | * @throws SequenceException if a Sequence is malformed - incorrect bases, etc.
65 | * @throws FormatException if there was an error in the format of the file.
66 | * @throws DelayAbortedException if the DelayCallback was aborted by the user.
67 | */
68 | SequenceList readFile(File file, DelayCallback delay)
69 | throws IOException, SequenceException, FormatException, DelayAbortedException;
70 |
71 | /**
72 | * Append this file to the specified SequenceList. This will read in all the sequences from the
73 | * file and append them directly onto the end of this SequenceList.
74 | *
75 | * @throws IOException if there was an error doing I/O
76 | * @throws SequenceException if a Sequence is malformed - incorrect bases, etc.
77 | * @throws FormatException if there was an error in the format of the file.
78 | * @throws DelayAbortedException if the DelayCallback was aborted by the user.
79 | */
80 | void appendFromFile(SequenceList appendTo, File fileFrom, DelayCallback delay)
81 | throws IOException, SequenceException, FormatException, DelayAbortedException;
82 |
83 | /**
84 | * Writes the content of this sequence list into a file. The file is overwritten. The order of
85 | * the sequences written into the file is guaranteed to be the same as in the list.
86 | *
87 | * @throws IOException if there was a problem creating/writing to the file.
88 | * @throws DelayAbortedException if the DelayCallback was aborted by the user.
89 | */
90 | void writeFile(File file, SequenceList set, DelayCallback delay)
91 | throws IOException, DelayAbortedException;
92 |
93 | /**
94 | * Checks to see if this file *might* be of this format. Good for internal loops.
95 | *
96 | *
No exceptions: implementors, please swallow them all up. If the file does not exist, it's
97 | * not very likely to be of this format, is it?
98 | */
99 | boolean mightBe(File file);
100 |
101 | /**
102 | * Add a new FormatListener to this FormatHandler. We'll keep the Listener notified during a
103 | * parse, so that he can chug up any other information which we can't stuff into the file.
104 | */
105 | void addFormatListener(FormatListener listener);
106 |
107 | /** Removes a FormatListener from this FormatHandler. */
108 | void removeFormatListener(FormatListener listener);
109 | }
110 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/SpeciesIdentifier/SystemUsage.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Displays current system usage, just so you know where you are.
3 | *
4 | * @author Gaurav Vaidya, gaurav@ggvaidya.com
5 | */
6 |
7 | /*
8 | TaxonDNA
9 | Copyright (C) Gaurav Vaidya, 2005
10 |
11 | This program is free software; you can redistribute it and/or modify
12 | it under the terms of the GNU General Public License as published by
13 | the Free Software Foundation; either version 2 of the License, or
14 | (at your option) any later version.
15 |
16 | This program is distributed in the hope that it will be useful,
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | GNU General Public License for more details.
20 |
21 | You should have received a copy of the GNU General Public License
22 | along with this program; if not, write to the Free Software
23 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 | */
25 |
26 | package com.ggvaidya.TaxonDNA.SpeciesIdentifier;
27 |
28 | import com.ggvaidya.TaxonDNA.Common.UI.*;
29 | import java.awt.*;
30 | import java.awt.event.*;
31 |
32 | public class SystemUsage extends Panel implements UIExtension, ActionListener, ComponentListener {
33 | private TextArea text_main = new TextArea();
34 | private Button button_Refresh = new Button("Optimize and refresh");
35 |
36 | public SystemUsage(SpeciesIdentifier seqId) {
37 | // layouting
38 | setLayout(new BorderLayout());
39 |
40 | button_Refresh.addActionListener(this);
41 | add(button_Refresh, BorderLayout.NORTH);
42 |
43 | text_main.setEditable(false);
44 | text_main.setFont(new Font("Monospaced", Font.PLAIN, 12));
45 | addComponentListener(this);
46 | add(text_main);
47 | }
48 |
49 | public void itemStateChanged(ItemEvent e) {}
50 |
51 | public void actionPerformed(ActionEvent evt) {
52 | // collect garbage!
53 | Runtime.getRuntime().gc();
54 | resetMemory();
55 | }
56 |
57 | public void componentHidden(ComponentEvent e) {}
58 |
59 | public void componentMoved(ComponentEvent e) {}
60 |
61 | public void componentResized(ComponentEvent e) {}
62 |
63 | public void componentShown(ComponentEvent e) {
64 | resetMemory();
65 | }
66 |
67 | public void resetMemory() {
68 | // listener only set on the TextArea
69 | StringBuffer buffer = new StringBuffer();
70 | Runtime runtime = Runtime.getRuntime();
71 |
72 | buffer.append(
73 | "Number of processors available: "
74 | + runtime.availableProcessors()
75 | + " processors\n");
76 | buffer.append("\n");
77 | buffer.append(
78 | "Maximum memory available for use: "
79 | + printMemory(runtime.maxMemory())
80 | + "\n");
81 | buffer.append(
82 | "Total memory available for use at the moment: "
83 | + printMemory(runtime.totalMemory())
84 | + "\n");
85 | buffer.append(
86 | "Free memory available for use at the moment: "
87 | + printMemory(runtime.freeMemory())
88 | + " ("
89 | + com.ggvaidya.TaxonDNA.Common.DNA.Settings.percentage(
90 | runtime.freeMemory(), runtime.totalMemory())
91 | + "%)\n");
92 |
93 | long totalUsedMemory = runtime.totalMemory() - runtime.freeMemory();
94 | long totalFreeMemory = runtime.maxMemory() - totalUsedMemory;
95 | buffer.append("\n");
96 | buffer.append(
97 | "Total memory used: "
98 | + printMemory(totalUsedMemory)
99 | + " ("
100 | + com.ggvaidya.TaxonDNA.Common.DNA.Settings.percentage(
101 | totalUsedMemory, runtime.maxMemory())
102 | + "%)\n");
103 | buffer.append(
104 | "Total memory free: "
105 | + printMemory(totalFreeMemory)
106 | + " ("
107 | + com.ggvaidya.TaxonDNA.Common.DNA.Settings.percentage(
108 | totalFreeMemory, runtime.maxMemory())
109 | + "%)\n");
110 |
111 | text_main.setText(buffer.toString());
112 | }
113 |
114 | private String printMemory(long memory) {
115 | // return DNA.Settings.percentage(memory, 1024) + " KB, or " +
116 | // DNA.Settings.percentage(memory,
117 | // 1024 * 1024) + " MB";
118 | if (memory == Long.MAX_VALUE) return "No limit";
119 |
120 | return com.ggvaidya.TaxonDNA.Common.DNA.Settings.roundOff(memory / (1024 * 1024))
121 | + " MB\t("
122 | + com.ggvaidya.TaxonDNA.Common.DNA.Settings.roundOff(memory / 1024)
123 | + " KB)";
124 | }
125 |
126 | public void dataChanged() {
127 | return;
128 | }
129 |
130 | public String getShortName() {
131 | return "System Usage";
132 | }
133 |
134 | public String getDescription() {
135 | return "Displays the current system usage";
136 | }
137 |
138 | public boolean addCommandsToMenu(Menu commandMenu) {
139 | return false;
140 | }
141 |
142 | public Panel getPanel() {
143 | return this;
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Sequence Matrix allows you to easily concatenate gene datasets. A spreadsheet-like interface displays what you've assembled so far; TNT, Nexus, FASTA and Mega files can be dragged into the application to add them. Your entire dataset can be exported as TNT or Nexus files.
If you get an "unidentified developer" error, please right-click on the file and select "Open": you should get the some error, but with an "Open" button that allows you to bypass it. Alternatively, you can change your security settings: go to System Preferences on your Mac, click on "Security & Privacy" and go to the "General" tab. If you set "All apps downloaded from:" to "Anywhere", Sequence Matrix should run without any problem.
37 |
38 |
39 | Testimonials
40 |
41 |
Here are some reviews of Sequence Matrix we've spotted around the internet.
42 |
43 |
44 |
"Thanks so much. This software has saved me many hours of tedious work." -- evanmelstad on YouTube.
45 |
46 |
"It is a real pain combining matrices from different loci, particularly when you have taxa represented in one matrix and not in another. I’ve usually done this by hand and it gets tedious. I recently stumbled across a Java tool that makes this process quite simple: SequenceMatrix." -- The Glor Lab, University of Rochester.
Species Identifier is no longer being actively maintained. If you want to
57 | repeat the analyses in
58 | Meier et al, 2006,
59 | you can download the latest release.
60 |
61 |
62 |
63 | Problems? Let us know!
64 |
65 |
If you find any bugs in this or any other release, please report them to us! The source code for this project is available on GitHub.
66 |
67 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/DNA/formats/SequencesHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * A handler for the 'commands' used by SequencesFile. A SequencesFile can contain arbitary
3 | * commands, either at the global level (e.g. '@seqlength 10353') or at the local level (e.g.
4 | * '^charset cds (203 - 402)'). The actual set of commands is extensible by use of the file
5 | * declaration on top of the file itself, which is in the format '#sequences (nucleotide
6 | * cancelledsequences)', implying that we are going to use nucleotide commands, as well as the
7 | * 'cancelledsequences' set of commands. This allows a loader to warn the user upfront about loosing
8 | * information: "This file contains 'cancelledsequences' information, which I cannot process. If you
9 | * export this file again, I cannot export the 'cancelledsequences' information again. Please use a
10 | * Sequences loader which can understand 'cancelledsequences'.
11 | *
12 | *
I can still load 'nucleotide' information from this file."
13 | *
14 | *
This is technically easy while reading a file, but much harder while writing a file, when we
15 | * won't know which commands we used until right at the very end. The solution is probably to just
16 | * cheat while writing the file: either buffer the whole thing in memory, then write it out at the
17 | * end, or use the old create-write-close-create-append technique (create a temp file, write to it,
18 | * close it, create the actual file, write in the first line, then write out the rest).
19 | *
20 | *
Either way, CommandHandlers are registered with the SequencesFile system. Unlike other parts
21 | * of TaxonDNA, COMMAND HANDLERS ARE REQUIRED TO BE SYMMETRICAL AND COMPLETE: any command read by
22 | * the file must be written back, unchanged, unless it WAS changed. Note that this only incorporates
23 | * commands the handler understands, so un-understood commands are dropped unceremoniously (we
24 | * should probably warn the user: but do we need to if we've already warned him about not supporting
25 | * 'cancelledsequences'?)
26 | *
27 | *
Another major problem: we cannot handle multiple command sets having the same commands! Only
28 | * one of the two will actually get the command, so we'll be missing information without knowing any
29 | * better. Since the only comprehensive solution is to actually disambiguate them (com.fresh...),
30 | * I'll settle right now for just keeping track of command lists. I'll leave a master list in the
31 | * repository which tracks this (look for sequences-commands.txt in the same directory as this
32 | * file).
33 | *
34 | *
Since fullstops are allowed in key names, for now, you can use a custom name (sequencematrix)
35 | * followed by a '.', and the rest of the stuff (e.g. 'sequencematrix.colname'). Using a full
36 | * com.... name would be really nice, too =)
37 | */
38 |
39 | /*
40 | TaxonDNA
41 | Copyright (C) 2005, 2006 Gaurav Vaidya
42 |
43 | This program is free software; you can redistribute it and/or modify
44 | it under the terms of the GNU General Public License as published by
45 | the Free Software Foundation; either version 2 of the License, or
46 | (at your option) any later version.
47 |
48 | This program is distributed in the hope that it will be useful,
49 | but WITHOUT ANY WARRANTY; without even the implied warranty of
50 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51 | GNU General Public License for more details.
52 |
53 | You should have received a copy of the GNU General Public License
54 | along with this program; if not, write to the Free Software
55 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
56 | */
57 |
58 | package com.ggvaidya.TaxonDNA.Common.DNA.formats;
59 |
60 | import com.ggvaidya.TaxonDNA.Common.DNA.*;
61 |
62 | public interface SequencesHandler {
63 | /**
64 | * A 'local command' line was read by SequencesFile.
65 | *
66 | * @param cmdLine The command line which was read in, including the initial '^'
67 | * @param seq The sequence currently being processed. Note that the sequence is guaranteed
68 | * complete: local commands are only processed AFTER the entire sequence is read (i.e. once
69 | * the next sequence begins), IN the order that they appeared.
70 | * @return true, if you understood this command and 'consumed' it.
71 | */
72 | boolean readLocalCommand(String cmdLine, Sequence seq) throws FormatException;
73 |
74 | /**
75 | * A 'global' command line was read by SequencesFile.
76 | *
77 | * @param cmdLine The command line which was read in, including the initial '@'
78 | * @param list The SequenceList on which this command is expected to work. Note that this is the
79 | * complete sequence list, as global commands are processed after loading is complete.
80 | * @return true, if you understood this command and 'consumed' it.
81 | */
82 | boolean readGlobalCommand(String cmdLine, SequenceList list) throws FormatException;
83 |
84 | /**
85 | * An opportunity to write a local command line for a particular sequence.
86 | *
87 | * @return The local command line to write, or 'null' if you don't have one. Try not to send
88 | * back zero-length strings, as we might write them into the file as a blank line, not to
89 | * mention adding them to the header. You can write multiple commands by separating them
90 | * with newlines.
91 | */
92 | String writeLocalCommand(Sequence seq);
93 |
94 | /**
95 | * An opportunity to write a global command line for a particular sequence.
96 | *
97 | * @return The global command line to write, or 'null' if you don't have one. Try not to send
98 | * back zero-length strings, as we might write them into the file as a blank line, not to
99 | * mention adding them to the header. You can write multiple commands by separating them
100 | * with newlines.
101 | */
102 | String writeGlobalCommand(SequenceList list);
103 |
104 | /**
105 | * Return the 'name' used by this module. This is the same name which we'll use in the header,
106 | * so no spaces. All spaces will be summarily turned into '_'.
107 | */
108 | String getSequencesHandlerName();
109 | }
110 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/SpeciesIdentifier/Messages.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Stores 'Messages' (strings which can be retrieved, and hence modified, from a central source).
3 | * We're trying to be simple: there'll be a set of codes, you call
4 | * Messages.getMessage(Messages.FILE_NOT_FOUND) to get a standard FILE_NOT_FOUND error string. Some
5 | * messages need an arguments (cast via Object), such as
6 | * Messages.getMessage(Messages.FILE_NOT_FOUND, file)
7 | *
8 | * @author Gaurav Vaidya, gaurav@ggvaidya.com
9 | */
10 | /*
11 | TaxonDNA
12 | Copyright (C) Gaurav Vaidya, 2005
13 |
14 | This program is free software; you can redistribute it and/or modify
15 | it under the terms of the GNU General Public License as published by
16 | the Free Software Foundation; either version 2 of the License, or
17 | (at your option) any later version.
18 |
19 | This program is distributed in the hope that it will be useful,
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | GNU General Public License for more details.
23 |
24 | You should have received a copy of the GNU General Public License
25 | along with this program; if not, write to the Free Software
26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 | */
28 |
29 | package com.ggvaidya.TaxonDNA.SpeciesIdentifier;
30 |
31 | import java.io.*;
32 |
33 | public class Messages {
34 | public static int SUCCESS = 0;
35 | public static int FILE_NOT_FOUND = 1;
36 | public static int CANT_READ_FILE = 2;
37 | public static int SAVE_FILE_FORMAT = 3;
38 | public static int READING_FILE = 4;
39 | public static int IOEXCEPTION_READING = 5;
40 | public static int IOEXCEPTION_WRITING = 6;
41 | public static int IOEXCEPTION_WRITING_NO_FILENAME = 7;
42 | public static int COPY_TO_CLIPBOARD_FAILED = 8;
43 | public static int NEED_SPECIES_SUMMARY = 9;
44 |
45 | private static String[] errorMessages = {
46 | // SUCCESS: No arguments
47 | "This operation was completely successfully.",
48 | // FILE_NOT_FOUND: The file which was not found
49 | "The file '$1$' was not found. Please ensure that the file exists.",
50 | // CANT_READ_FILE: The file which could not be read
51 | "The file '$1$' could not be read. Please check whether the file exists, and that you have"
52 | + " sufficient permissions to read this file.",
53 | // SAVE_FILE_FORMAT
54 | "Saving file '$1$' in the $2$ format. To save export this file to another format, you may"
55 | + " use the 'Export' menu.",
56 | // READING_FILE:
57 | "Reading sequences from '$1$' into SpeciesIdentifier. This might take some time.",
58 | // IOEXCEPTION_READING: file, exception
59 | "There was an error while reading from '$1$'. Please ensure that the file exists, that you"
60 | + " have permission to read it, and that there are no problems with the drive on which"
61 | + " the file is being read from.\n\n"
62 | + "The technical description of this error is: $2$",
63 | // IOEXCEPTION_WRITING: file, exception
64 | "There was an error while writing to '$1$'. Please ensure that you have permission to"
65 | + " create or modify this file, that the drive on which the file is being written is"
66 | + " not full or set 'write-only'.\n\n"
67 | + "The technical description of this error is: $2$",
68 | // IOEXCEPTION_WRITING_NO_FILENAME: exception
69 | "There was an error while trying to write a file. Please ensure that the drive on which the"
70 | + " file is being written is not full or set 'write-only'.\n\n"
71 | + "The technical description of this error is: $1$",
72 | // COPY_TO_CLIPBOARD_FAILED: exception
73 | "There was an error copying to the clipboard. The text was probably not copied. Please try"
74 | + " again; if this doesn't work, please report it as a bug.\n\n"
75 | + "Technical explanation: $1$",
76 | // NEED_SPECIES_SUMMARY
77 | "To carry out this operation, I need the Species Summary module, which was not built into"
78 | + " your SpeciesIdentifier. You can try downloading the most recent one, or download"
79 | + " the \"definitive\" copy from http://taxondna.sf.net/"
80 | };
81 |
82 | public static String getMessage(int code) {
83 | if (code >= 0 && code < errorMessages.length) {
84 | return errorMessages[code];
85 | }
86 |
87 | return "An illegal error code occured (error code "
88 | + code
89 | + "). This is a programming error. Please contact the developer(s) at"
90 | + " http://taxondna.sf.net/.";
91 | }
92 |
93 | public static String getMessage(int code, Object arg) {
94 | String message = getMessage(code);
95 | String textArg = makeText(arg);
96 |
97 | if (textArg != null)
98 | message = message.replaceAll("\\$1\\$", textArg.replaceAll("\\\\", "\\\\\\\\"));
99 |
100 | return message;
101 | }
102 |
103 | public static String getMessage(int code, Object arg, Object arg2) {
104 | String message = getMessage(code);
105 | String textArg = makeText(arg);
106 | String textArg2 = makeText(arg2);
107 |
108 | if (textArg != null)
109 | message = message.replaceAll("\\$1\\$", textArg.replaceAll("\\\\", "\\\\\\\\"));
110 |
111 | if (textArg2 != null)
112 | message = message.replaceAll("\\$2\\$", textArg2.replaceAll("\\\\", "\\\\\\\\"));
113 |
114 | return message;
115 | }
116 |
117 | private static String makeText(Object obj) {
118 | // handle null objects
119 | if (obj == null) return "(null)";
120 |
121 | // see if it's a class we recognize
122 | if (File.class.isAssignableFrom(obj.getClass())) {
123 | // it's a file!
124 | return ((File) obj).getAbsolutePath();
125 | }
126 |
127 | if (String.class.isAssignableFrom(obj.getClass())) {
128 | // it's a string!
129 | return (String) obj;
130 | }
131 |
132 | return obj.toString();
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/Release/SequenceMatrix/Sample files/Example_1_Primates_fasta/atp8.fas:
--------------------------------------------------------------------------------
1 | >Cebus_albifrons
2 | GTGCCACAACTAGACATCTCACCATGACCAATGGTGACTTTATCAATGATTTTAACCCTGTTNNNNGCTA
3 | TACAACTAAAAATATTAAAATTTATTTTCCACACTACCCCACTATCAAAA---TTAACTAAAATTCAAAA
4 | CCAAAAAACAACCTGAGAACTAAAATGAACCAAAATCTATTTGCCTCTTTCAATATACCAA??????
5 | >Chlorocebus_aethiops
6 | ATGCCTCAATTAGATACATCCACATGATTTATCACTATCACAACAACACTCCCTACACTATATCTTATTA
7 | CACAACTAAAACTGCTAAACACACATTACTATCAACCCCCCCAACAAAAA---AACTCTCATAAGCAAAC
8 | CCCCAATAACCACTGACAACTAAAATGAACGAAAATCTATTTACCTTATTCGCAACTCCAA??????
9 | >Chlorocebus_sabaeus
10 | ATGCCTCAATTAGACACATCCACATGATTTATCACTATTACAACAATACTCCCTACACTATATCTTATTA
11 | CACAACTAAAACTGCTAGACATATGTTACTATCAATCCCCCCAACAAAAA---AACTCTRACAAGCAAAC
12 | CCCCAATAACCACTGACAACTAAAATGAACGAAAATTTATTTACCTTATTCGCAACTCCAA??????
13 | >Colobus_guereza
14 | ATGCCTCAACTAAATACATCCACATGGTTCACTATCATTATAACCATACTCCCCACACTATATATCATTA
15 | TACAATTAAAATTACTAAGTACAACCTATTATCCATCTCCACCACAAAAA---TTAGCTAAGACAAAACC
16 | CCGCAACAATCCTTGACAACTAAAATGAACGAAAATTTATTTACCCCATTCACAACTCCAACAATCC
17 | >Daubentonia_madagascariensis
18 | ATGCCCCAACTAGACACATCAACATGACCTATCATCATTCTTTCGATGATCCTAACACTCTTCATTATAC
19 | TCCAACTAAAAACATTAAAACTTGTATTCCCCCTAAACCCGGCACCCAAA---AATATAACAACACAAAA
20 | ATATAACAACCCCTGAGAAATAAAATGAACGAAAATTTATTCGCCTCTTTCATTACCCCTACAATCA
21 | >Eulemur_mongoz
22 | ATGCCTCAACTCAACACATCAACATGGCCAATTACAATTCTCTCCATAATTTTGACCCTACTAATTGTTT
23 | TTCAACTGAAAATTTCAAAATTCAATTACCCCCTAAGCCTGACATTAAAA---GACACTAATAAATATTC
24 | ACACGTTAGTCCTTGAGAAACAAAATGAACGAAAATTTATTTGCCTCTTTCATTACCCCAACAATTG
25 | >Gorilla_gorilla
26 | ATGCCCCAGCTAAATACCACCGTATGGCNNNNCATAATTGCCCCAATACTCCTCACACTATTTCTCATTA
27 | CCCAACTAAAAGTTTTAAACACAAATTACCACCTACCCCCCTTACCAAAA---ACTATAAAAATAAAAAA
28 | CTTCTGTAAACCCTGAGAATCAAAATGAACGAAAATTTATTCGCTTCATTCATTGCCCCCACAATCC
29 | >Homo_neanderthalensis
30 | ATGCCCCAACNNNNTACTACTGTATGGCCCACCATAATTATCCCCATACTCCTTACACTATTCCTCATCA
31 | CCCAACTAAAAATATTAAATACAAATTACCACTTACCTCCCTCACCAAAG---CCCATAAAAATAAAAAA
32 | CTATAACAAACCCTGAGAACCAAAATGAACGAAAATCTGTTCGCTTCATTCATTGCCCCCACAATCC
33 | >Homo_sapiens
34 | ATGCCCCAACTAAATACTACCGTATGGCCCACCATAATTACCCCCATACTCCTTACACTATTCCTCATCA
35 | CCCAACTAAAAATATTAAACACAAACTACCACCTACCTCCCTCACCAAAG---CCCATAAAAATAAAAAA
36 | TTATAACAAACCCTGAGAACCAAAATGAACGAAAATCTGTTCGCTTCATTCATTGCCCCCACAATCC
37 | >Hylobates_lar
38 | ATGCCCCAATTAAACACCACCGTGTGACCTACAATCATCATATCAATACTCCTCGCACTATTCCTCCTTA
39 | TACAGCTGAAAACACTAAATACACACTACCACCCACCCGCCTCCCCAAAA---CTCACGAACATTAAACC
40 | TCATAATAATCCCTGAGAACACAAATGAACGAAAATCTATTCACTTCATTCGCTACCCCCACAATTC
41 | >Lemur_catta
42 | ATGCCTCAACTTGACACATCAACATGGCTAATTACAATTCTTTCCATAATCNNNNCCCTATTAATTGTTT
43 | TTCAACTGAAAATCTCAAAATTCAACTATCCTTTAAATCCAACAATAAAA---AATATTAATAAAGACCT
44 | ATATACTAACCCCTGAGAAACTAAATGAACGAAAATTTATTTGCCTCTTTCATTACCCCAACAATCG
45 | >Macaca_mulatta
46 | ATGCCCCAGTTAGATACATCAACATGATTCACCACTATTATGACGATGCTTCCCACACTATATCTTATCA
47 | TGCAGCTAAAGCTACTAAACACAAATCACCACCAACCACCCCTTACAAAA---ACCCCCACCCTTCAGTC
48 | TCACAATGTCCGCTGACAACCAAAATGAACGAAAACTTGTTTACCCCTTTCTCAGCCCCAACAATTC
49 | >Macaca_sylvanus
50 | ATGCCCCAATTAGACACATCGACATGATCCACCACTATTATAGCAATACTTCCTACACTATACCTTATTA
51 | CACAACTAAAACTACTAAACACAAACTACTATCAACCACCTCTTACAAAA---AACCCCAACCTACAAAC
52 | CCACAATATCTACTGGCAACCAGAATGAACGAAAACCTGTTTACCCCATTCTCAACCCCAA??????
53 | >Macaca_thibetana
54 | GTGCCCCAGTTAGATACATCGACATGATTCACCACCATTATAACGACACTTCCCACACTATATCTTATCA
55 | TACAATTAAAACTACTAAACATAAACCACTACCAACCGCCTCTTGCAAAA---AACTCGAACCTGCAACC
56 | TCGCAATACCCATTGACAACCAAAATGAACGAAAACCTGTTTACCTCTTTCTCAACCCCAACAATCC
57 | >Mus_musculus
58 | ATGCCACAACTAGATACATCAACATGATTTATCACAATTATATCATCAATAATTACCCTATTTATCTTAT
59 | TTCAACTAAAAGTCTCATCACAAACATTCCCACTAGCACCTTCACCAAAA---TCACTAACAACCATAAA
60 | AGTAAAAACCCCTTGAGAATTAAAATGAACGAAAATCTATTTGCCTCATTCATTACCCCAACAA???
61 | >Nasalis_larvatus
62 | ATGCCTCAACTAAATACATCCACGTGGTTTATTACTATTATAGCCATGCTGCCCGCACTTTACCTTATCA
63 | TACAATTAAAGCTACTAAACACAACCTACCATTTCTCCCCGTCACAAAAA---GTCCTTAGTATACAAAC
64 | AACTAACAATTCTTGACAACTAAAATGAACGAAAATTTATTTACCCCATTCACAACCCCAACACTCT
65 | >Nycticebus_coucang
66 | ATGCCACAACTAGATACATCAACATGGACTATCACTATCATGTCTATAATTCTANNNNTTTTTATTTTAT
67 | TCCAACTAAAACTGTCAAAATTTATATACCCTACGAACCCTACCAAAAAA---CTCACAAAACCACACAA
68 | GCTAGAAAGCCCATGAGAGATAAAATGGACCAAAACTTATTTGCCTCATTCATTACCCCTACAA???
69 | >Pan_paniscus
70 | ATGCCCCAACTAAATACCGCCGTATGACCCACCACAATTACCCCTATACTCCTTACACTATTTCTTATCA
71 | CCCAACTAAAAATATTAAACTCAAATTACCATCTACCCCCCTCACCAAAA---CCCATAAAAATAAAAAA
72 | CTACAATAAACCCTGAGAACCAAAATGAACGAAAATCTGTTCGCTTCATTCGCTGCCCCCACAATCC
73 | >Pan_troglodytes
74 | ATGCCCCAACTAAATACCGCCGTATGACCCACCATAATTACCCCCATACTCCTGACACTATTTCTCGTCA
75 | CCCAACTAAAAATATTAAATTCAAATTACCATCTACCCCCCTCACCAAAA---CCCATAAAAATAAAAAA
76 | CTACAATAAACCCTGAGAACCAAAATGAACGAAAATCTATTCGCTTCATTCGCTGCCCCCACAATCC
77 | >Papio_hamadryas
78 | ATGCCCCAACTGGACACATCCACATGATTCACTATTATCATAGCAATACTTCCCACACTATACCTTATCA
79 | CACAGTTAAAACTGCTAAGCATAAACTACTATCAACCTCCCCTCACAAAA---AACCCCAACTTACAAAC
80 | CCACAACACCTGTTGACGGCCAAAATGAACGAAAACCTATTTACCTCATTCTCAGCCCCAACAATCC
81 | >Piliocolobus_badius
82 | ATGCCTCAACTAAATACANNNACATGGTTTATTGTAATTATAACCATACTTCCCACATTATATATTATTA
83 | TACAATTAAAATTATTGAGCACAAATTATTATCCCCACCCCTCACAAAAT---TTCTCTAAAATACAGAC
84 | CCACAATAACCCCTGACAACTAAAATGAACGAAAATTTATTCGCCTCTTTCA???????????????
85 | >Pongo_pygmaeus
86 | ATGCCCCAACTAAATACCACCACATGGCTCACCGTCATCACTCCAACACTTCTTGCACTATTCCTCATCA
87 | CCCAGTTAAAACTATTAAACTCACACCTCCACCCACCCACCCCACCAAAA---TTTACCAAAACAAAACC
88 | CCACGCCAAACCCTGAGAACTAAAATGAACGAAGATCTATTCACCCCATTCACTACCCCCACAGTCC
89 | >Presbytis_melalophos
90 | ATGCCTCAACTAAATACGTCTACATGGCTTATTACTATTATTACCATGTTACCTACATTATATCTAATTA
91 | TACAATTAAAATTACTAAGCATAAATTATCATTTATCCCCATTACAAAAA---AATCCTAATATACGAAT
92 | ATTTAACAACCCTTGACAACTAAAATGAACGAAAATTTATTTACCCCATTCACAACCCCAACATTCC
93 | >Pygathrix_nemaeus
94 | ATGCCTCAACTAAATACATCTACATGGCTAATTACTATTATAANNNNGCTACCCGCACTATATCTCATTA
95 | TACAACTAAAACTATTAAATATAGTCTACTATTTTCCCCCGTCACAAAAA---GTCTCTAGTACGCAAAT
96 | ATTCAACAACCCCTGACAACTAAAATGAACGAAAATTTATTTACCTCATTTACACACCCAACACTCC
97 | >Rattus_norvegicus
98 | ATGCCACAACTAGACACATCCACATGATTTATTACAATCATCTCCTCAATAGCCACACTATTTATTTTAT
99 | TTCAATTAAAAATTTCTTCCCAAACCTTTCCTGCACCTCCCTCACCCAAA---ACTATAGCCACAGAAAA
100 | AACGAATAACCCTTGAGAATCAAAATGAACGAAAATCTATTTGCCTCTTTCATTACCCCCACAA???
101 | >Semnopithecus_entellus
102 | ATGCCTCAGCTAAACACATCTACATGATTTATTACTATTATTACCATACTACCTACACTATATCTTATTA
103 | TACAACTAAAATTATTAAAAACAACTTATTATTTTTCTCCCTCACAAAAA---GCCTCTGACATACAATC
104 | ATTTAATAACCCCTGACAATTAAAATGAACGAAAATTTGTTTGCCCCTTTCACAGCTCCATCACTCC
105 | >Trachypithecus_obscurus
106 | ATGCCTCAACTAAACACATCTACATGGTTTATTACCATTATAACCATGCTACCTGCACTTTACCTTATTA
107 | TACAATTAAAATTACTAAATACAAACTACTATTTGCCCCCAACACAAAAA---ACCCCTAATACGCAAAT
108 | ATTTAATAACTCTTGACAACTAAAATGAACGAAAATTTATTTACCCCATTTACAACCCCAACACTCC
109 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/Common/UI/LargeTextArea.java:
--------------------------------------------------------------------------------
1 | /**
2 | * LargeTextArea
3 | *
4 | *
Sometimes, TextAreas just aren't large enough. On some systems, TextArea.setText() is silently
5 | * ignored if the text is too big. On other systems, somebody throws an OutOfMemoryError. It's all
6 | * pretty random, so I'm just going to create a class to deal with it ALL.
7 | *
8 | *
Basically, it'll: 1. Use 'try' to make sure that nothing goes wrong with the setText. 2. Check
9 | * it see if the text got written successfully (by using getText() to get a back: a memory load, if
10 | * ever there was one, but what else can we do?) 3. If it DIDN'T, it warns you and asks if you'd
11 | * like to dump the output to a file. Pretty simple interface: MessageBox to ask, FileDialog to
12 | * indicate location, and - hell - ProgressDialog to save.
13 | *
14 | *
It's a neat enough solution; have no idea if it will actually WORK. Lesse.
15 | */
16 |
17 | /*
18 | TaxonDNA
19 | Copyright (C) 2006 Gaurav Vaidya
20 |
21 | This program is free software; you can redistribute it and/or modify
22 | it under the terms of the GNU General Public License as published by
23 | the Free Software Foundation; either version 2 of the License, or
24 | (at your option) any later version.
25 |
26 | This program is distributed in the hope that it will be useful,
27 | but WITHOUT ANY WARRANTY; without even the implied warranty of
28 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 | GNU General Public License for more details.
30 |
31 | You should have received a copy of the GNU General Public License
32 | along with this program; if not, write to the Free Software
33 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 | */
35 |
36 | package com.ggvaidya.TaxonDNA.Common.UI;
37 |
38 | import java.awt.*;
39 | import java.io.*;
40 |
41 | public class LargeTextArea extends TextArea {
42 | private Frame frame = null;
43 | private String ourString = new String("");
44 |
45 | public void setFrame(Frame frame) {
46 | this.frame = frame;
47 | }
48 |
49 | public synchronized String getText() {
50 | return ourString;
51 | }
52 |
53 | public synchronized void append(String str) {
54 | setText(getText() + str);
55 | }
56 |
57 | public synchronized void appendString(String str) {
58 | setText(getText() + str);
59 | }
60 |
61 | public synchronized void setText(String str) {
62 | ourString = str;
63 |
64 | try {
65 | super.setText(str);
66 |
67 | if (super.getText().equals(str)) {
68 | // don't change this!
69 | // we can't use OUR getText
70 | // since that's overloaded
71 | // to return the 'correct'
72 | // text.
73 |
74 | // if we're here, the text
75 | // changed successfully.
76 | // Good show.
77 | return;
78 | }
79 | } catch (Throwable e) {
80 | // fall through
81 | }
82 |
83 | // okay, so the text:
84 | // 1. didn't change (silently), or
85 | // 2. threw some kind of exception while changing
86 |
87 | // solution: tell the user!
88 | // how can we signal to the user that something catastrophic happened?
89 | // haha! easy!
90 | super.setText(
91 | "Results should be displayed here now, but we are out of memory.\n"
92 | + "There is a chance that other buttons on this page MIGHT work. Give them a"
93 | + " shot.\n"
94 | + "Allocating more memory for this program to run might help, too (see the"
95 | + " README file).");
96 |
97 | if (frame != null) {
98 | MessageBox mb =
99 | new MessageBox(
100 | frame,
101 | "The results cannot be displayed! Write to file?",
102 | "Results have been calculated, but cannot be displayed, because of"
103 | + " limitations imposed by the operating system. Allocating more"
104 | + " memory for this program might help (see the README file).\n\n"
105 | + "Would you like me to write the results to a file instead?",
106 | MessageBox.MB_YESNO);
107 | if (mb.showMessageBox() == MessageBox.MB_YES) {
108 | FileDialog fd =
109 | new FileDialog(
110 | frame,
111 | "Where would you like to save the results?",
112 | FileDialog.SAVE);
113 |
114 | fd.setVisible(true); // go!
115 |
116 | while (true) {
117 | String filename = "";
118 | if (fd.getFile() != null) {
119 | if (fd.getDirectory() != null) filename = fd.getDirectory() + fd.getFile();
120 | else filename = fd.getFile();
121 | } else {
122 | // he 'cancelled' the file dialog
123 | break;
124 | }
125 |
126 | // So now we have a FileDialog
127 | try {
128 | PrintWriter writer = new PrintWriter(new FileWriter(filename));
129 |
130 | writer.print(str);
131 | writer.close();
132 |
133 | return;
134 | } catch (IOException e) {
135 | MessageBox mbError =
136 | new MessageBox(
137 | frame,
138 | "Something went wrong!",
139 | "There was an error writing '"
140 | + filename
141 | + "'. The exact technical description is: "
142 | + e
143 | + "\n\nWould you like to try again?",
144 | MessageBox.MB_YESNO);
145 | if (mbError.showMessageBox() == MessageBox.MB_YES) {
146 | continue;
147 | } else {
148 | break;
149 | }
150 | }
151 | }
152 | }
153 | }
154 | }
155 | }
156 |
--------------------------------------------------------------------------------
/Release/SequenceMatrix/Sample files/Example_1_Primates_tnt/atp8.tnt:
--------------------------------------------------------------------------------
1 | nstates 32;
2 | xread
3 | 'Written by TaxonDNA 1.7.6 on Sat Jun 05 18:56:21 SGT 2010'
4 | 207 27
5 |
6 | Cebus_albifrons GTGCCACAACTAGACATCTCACCATGACCAATGGTGACTTTATCAATGATTTTAACCCTGTTNNNNGCTATACAACTAAAAATATTAAAATTTATTTTCCACACTACCCCACTATCAAAA---TTAACTAAAATTCAAAACCAAAAAACAACCTGAGAACTAAAATGAACCAAAATCTATTTGCCTCTTTCAATATACCAA??????
7 | Chlorocebus_aethiops ATGCCTCAATTAGATACATCCACATGATTTATCACTATCACAACAACACTCCCTACACTATATCTTATTACACAACTAAAACTGCTAAACACACATTACTATCAACCCCCCCAACAAAAA---AACTCTCATAAGCAAACCCCCAATAACCACTGACAACTAAAATGAACGAAAATCTATTTACCTTATTCGCAACTCCAA??????
8 | Chlorocebus_sabaeus ATGCCTCAATTAGACACATCCACATGATTTATCACTATTACAACAATACTCCCTACACTATATCTTATTACACAACTAAAACTGCTAGACATATGTTACTATCAATCCCCCCAACAAAAA---AACTCTRACAAGCAAACCCCCAATAACCACTGACAACTAAAATGAACGAAAATTTATTTACCTTATTCGCAACTCCAA??????
9 | Colobus_guereza ATGCCTCAACTAAATACATCCACATGGTTCACTATCATTATAACCATACTCCCCACACTATATATCATTATACAATTAAAATTACTAAGTACAACCTATTATCCATCTCCACCACAAAAA---TTAGCTAAGACAAAACCCCGCAACAATCCTTGACAACTAAAATGAACGAAAATTTATTTACCCCATTCACAACTCCAACAATCC
10 | Daubentonia_madagascariensis ATGCCCCAACTAGACACATCAACATGACCTATCATCATTCTTTCGATGATCCTAACACTCTTCATTATACTCCAACTAAAAACATTAAAACTTGTATTCCCCCTAAACCCGGCACCCAAA---AATATAACAACACAAAAATATAACAACCCCTGAGAAATAAAATGAACGAAAATTTATTCGCCTCTTTCATTACCCCTACAATCA
11 | Eulemur_mongoz ATGCCTCAACTCAACACATCAACATGGCCAATTACAATTCTCTCCATAATTTTGACCCTACTAATTGTTTTTCAACTGAAAATTTCAAAATTCAATTACCCCCTAAGCCTGACATTAAAA---GACACTAATAAATATTCACACGTTAGTCCTTGAGAAACAAAATGAACGAAAATTTATTTGCCTCTTTCATTACCCCAACAATTG
12 | Gorilla_gorilla ATGCCCCAGCTAAATACCACCGTATGGCNNNNCATAATTGCCCCAATACTCCTCACACTATTTCTCATTACCCAACTAAAAGTTTTAAACACAAATTACCACCTACCCCCCTTACCAAAA---ACTATAAAAATAAAAAACTTCTGTAAACCCTGAGAATCAAAATGAACGAAAATTTATTCGCTTCATTCATTGCCCCCACAATCC
13 | Homo_neanderthalensis ATGCCCCAACNNNNTACTACTGTATGGCCCACCATAATTATCCCCATACTCCTTACACTATTCCTCATCACCCAACTAAAAATATTAAATACAAATTACCACTTACCTCCCTCACCAAAG---CCCATAAAAATAAAAAACTATAACAAACCCTGAGAACCAAAATGAACGAAAATCTGTTCGCTTCATTCATTGCCCCCACAATCC
14 | Homo_sapiens ATGCCCCAACTAAATACTACCGTATGGCCCACCATAATTACCCCCATACTCCTTACACTATTCCTCATCACCCAACTAAAAATATTAAACACAAACTACCACCTACCTCCCTCACCAAAG---CCCATAAAAATAAAAAATTATAACAAACCCTGAGAACCAAAATGAACGAAAATCTGTTCGCTTCATTCATTGCCCCCACAATCC
15 | Hylobates_lar ATGCCCCAATTAAACACCACCGTGTGACCTACAATCATCATATCAATACTCCTCGCACTATTCCTCCTTATACAGCTGAAAACACTAAATACACACTACCACCCACCCGCCTCCCCAAAA---CTCACGAACATTAAACCTCATAATAATCCCTGAGAACACAAATGAACGAAAATCTATTCACTTCATTCGCTACCCCCACAATTC
16 | Lemur_catta ATGCCTCAACTTGACACATCAACATGGCTAATTACAATTCTTTCCATAATCNNNNCCCTATTAATTGTTTTTCAACTGAAAATCTCAAAATTCAACTATCCTTTAAATCCAACAATAAAA---AATATTAATAAAGACCTATATACTAACCCCTGAGAAACTAAATGAACGAAAATTTATTTGCCTCTTTCATTACCCCAACAATCG
17 | Macaca_mulatta ATGCCCCAGTTAGATACATCAACATGATTCACCACTATTATGACGATGCTTCCCACACTATATCTTATCATGCAGCTAAAGCTACTAAACACAAATCACCACCAACCACCCCTTACAAAA---ACCCCCACCCTTCAGTCTCACAATGTCCGCTGACAACCAAAATGAACGAAAACTTGTTTACCCCTTTCTCAGCCCCAACAATTC
18 | Macaca_sylvanus ATGCCCCAATTAGACACATCGACATGATCCACCACTATTATAGCAATACTTCCTACACTATACCTTATTACACAACTAAAACTACTAAACACAAACTACTATCAACCACCTCTTACAAAA---AACCCCAACCTACAAACCCACAATATCTACTGGCAACCAGAATGAACGAAAACCTGTTTACCCCATTCTCAACCCCAA??????
19 | Macaca_thibetana GTGCCCCAGTTAGATACATCGACATGATTCACCACCATTATAACGACACTTCCCACACTATATCTTATCATACAATTAAAACTACTAAACATAAACCACTACCAACCGCCTCTTGCAAAA---AACTCGAACCTGCAACCTCGCAATACCCATTGACAACCAAAATGAACGAAAACCTGTTTACCTCTTTCTCAACCCCAACAATCC
20 | Mus_musculus ATGCCACAACTAGATACATCAACATGATTTATCACAATTATATCATCAATAATTACCCTATTTATCTTATTTCAACTAAAAGTCTCATCACAAACATTCCCACTAGCACCTTCACCAAAA---TCACTAACAACCATAAAAGTAAAAACCCCTTGAGAATTAAAATGAACGAAAATCTATTTGCCTCATTCATTACCCCAACAA???
21 | Nasalis_larvatus ATGCCTCAACTAAATACATCCACGTGGTTTATTACTATTATAGCCATGCTGCCCGCACTTTACCTTATCATACAATTAAAGCTACTAAACACAACCTACCATTTCTCCCCGTCACAAAAA---GTCCTTAGTATACAAACAACTAACAATTCTTGACAACTAAAATGAACGAAAATTTATTTACCCCATTCACAACCCCAACACTCT
22 | Nycticebus_coucang ATGCCACAACTAGATACATCAACATGGACTATCACTATCATGTCTATAATTCTANNNNTTTTTATTTTATTCCAACTAAAACTGTCAAAATTTATATACCCTACGAACCCTACCAAAAAA---CTCACAAAACCACACAAGCTAGAAAGCCCATGAGAGATAAAATGGACCAAAACTTATTTGCCTCATTCATTACCCCTACAA???
23 | Pan_paniscus ATGCCCCAACTAAATACCGCCGTATGACCCACCACAATTACCCCTATACTCCTTACACTATTTCTTATCACCCAACTAAAAATATTAAACTCAAATTACCATCTACCCCCCTCACCAAAA---CCCATAAAAATAAAAAACTACAATAAACCCTGAGAACCAAAATGAACGAAAATCTGTTCGCTTCATTCGCTGCCCCCACAATCC
24 | Pan_troglodytes ATGCCCCAACTAAATACCGCCGTATGACCCACCATAATTACCCCCATACTCCTGACACTATTTCTCGTCACCCAACTAAAAATATTAAATTCAAATTACCATCTACCCCCCTCACCAAAA---CCCATAAAAATAAAAAACTACAATAAACCCTGAGAACCAAAATGAACGAAAATCTATTCGCTTCATTCGCTGCCCCCACAATCC
25 | Papio_hamadryas ATGCCCCAACTGGACACATCCACATGATTCACTATTATCATAGCAATACTTCCCACACTATACCTTATCACACAGTTAAAACTGCTAAGCATAAACTACTATCAACCTCCCCTCACAAAA---AACCCCAACTTACAAACCCACAACACCTGTTGACGGCCAAAATGAACGAAAACCTATTTACCTCATTCTCAGCCCCAACAATCC
26 | Piliocolobus_badius ATGCCTCAACTAAATACANNNACATGGTTTATTGTAATTATAACCATACTTCCCACATTATATATTATTATACAATTAAAATTATTGAGCACAAATTATTATCCCCACCCCTCACAAAAT---TTCTCTAAAATACAGACCCACAATAACCCCTGACAACTAAAATGAACGAAAATTTATTCGCCTCTTTCA???????????????
27 | Pongo_pygmaeus ATGCCCCAACTAAATACCACCACATGGCTCACCGTCATCACTCCAACACTTCTTGCACTATTCCTCATCACCCAGTTAAAACTATTAAACTCACACCTCCACCCACCCACCCCACCAAAA---TTTACCAAAACAAAACCCCACGCCAAACCCTGAGAACTAAAATGAACGAAGATCTATTCACCCCATTCACTACCCCCACAGTCC
28 | Presbytis_melalophos ATGCCTCAACTAAATACGTCTACATGGCTTATTACTATTATTACCATGTTACCTACATTATATCTAATTATACAATTAAAATTACTAAGCATAAATTATCATTTATCCCCATTACAAAAA---AATCCTAATATACGAATATTTAACAACCCTTGACAACTAAAATGAACGAAAATTTATTTACCCCATTCACAACCCCAACATTCC
29 | Pygathrix_nemaeus ATGCCTCAACTAAATACATCTACATGGCTAATTACTATTATAANNNNGCTACCCGCACTATATCTCATTATACAACTAAAACTATTAAATATAGTCTACTATTTTCCCCCGTCACAAAAA---GTCTCTAGTACGCAAATATTCAACAACCCCTGACAACTAAAATGAACGAAAATTTATTTACCTCATTTACACACCCAACACTCC
30 | Rattus_norvegicus ATGCCACAACTAGACACATCCACATGATTTATTACAATCATCTCCTCAATAGCCACACTATTTATTTTATTTCAATTAAAAATTTCTTCCCAAACCTTTCCTGCACCTCCCTCACCCAAA---ACTATAGCCACAGAAAAAACGAATAACCCTTGAGAATCAAAATGAACGAAAATCTATTTGCCTCTTTCATTACCCCCACAA???
31 | Semnopithecus_entellus ATGCCTCAGCTAAACACATCTACATGATTTATTACTATTATTACCATACTACCTACACTATATCTTATTATACAACTAAAATTATTAAAAACAACTTATTATTTTTCTCCCTCACAAAAA---GCCTCTGACATACAATCATTTAATAACCCCTGACAATTAAAATGAACGAAAATTTGTTTGCCCCTTTCACAGCTCCATCACTCC
32 | Trachypithecus_obscurus ATGCCTCAACTAAACACATCTACATGGTTTATTACCATTATAACCATGCTACCTGCACTTTACCTTATTATACAATTAAAATTACTAAATACAAACTACTATTTGCCCCCAACACAAAAA---ACCCCTAATACGCAAATATTTAATAACTCTTGACAACTAAAATGAACGAAAATTTATTTACCCCATTTACAACCCCAACACTCC
33 | ;
34 | xgroup
35 | =0 (pos1) 0 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 102 105 108 111 114 117 120 123 126 129 132 135 138 141 144 147 150 153 156 159 162 165 168 171 174 177 180 183 186 189 192 195 198 201 204
36 | =1 (pos2) 1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82 85 88 91 94 97 100 103 106 109 112 115 118 121 124 127 130 133 136 139 142 145 148 151 154 157 160 163 166 169 172 175 178 181 184 187 190 193 196 199 202 205
37 | =2 (pos3) 2 5 8 11 14 17 20 23 26 29 32 35 38 41 44 47 50 53 56 59 62 65 68 71 74 77 80 83 86 89 92 95 98 101 104 107 110 113 116 119 122 125 128 131 134 137 140 143 146 149 152 155 158 161 164 167 170 173 176 179 182 185 188 191 194 197 200 203 206
38 |
39 | ;
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/docs/stylesheets/stylesheet.css:
--------------------------------------------------------------------------------
1 | * {
2 | box-sizing: border-box; }
3 |
4 | body {
5 | padding: 0;
6 | margin: 0;
7 | font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
8 | font-size: 16px;
9 | line-height: 1.5;
10 | color: #606c71; }
11 |
12 | a {
13 | color: #1e6bb8;
14 | text-decoration: none; }
15 | a:hover {
16 | text-decoration: underline; }
17 |
18 | .btn {
19 | display: inline-block;
20 | margin-bottom: 1rem;
21 | color: rgba(255, 255, 255, 0.7);
22 | background-color: rgba(255, 255, 255, 0.08);
23 | border-color: rgba(255, 255, 255, 0.2);
24 | border-style: solid;
25 | border-width: 1px;
26 | border-radius: 0.3rem;
27 | transition: color 0.2s, background-color 0.2s, border-color 0.2s; }
28 | .btn + .btn {
29 | margin-left: 1rem; }
30 |
31 | .btn:hover {
32 | color: rgba(255, 255, 255, 0.8);
33 | text-decoration: none;
34 | background-color: rgba(255, 255, 255, 0.2);
35 | border-color: rgba(255, 255, 255, 0.3); }
36 |
37 | @media screen and (min-width: 64em) {
38 | .btn {
39 | padding: 0.75rem 1rem; } }
40 |
41 | @media screen and (min-width: 42em) and (max-width: 64em) {
42 | .btn {
43 | padding: 0.6rem 0.9rem;
44 | font-size: 0.9rem; } }
45 |
46 | @media screen and (max-width: 42em) {
47 | .btn {
48 | display: block;
49 | width: 100%;
50 | padding: 0.75rem;
51 | font-size: 0.9rem; }
52 | .btn + .btn {
53 | margin-top: 1rem;
54 | margin-left: 0; } }
55 |
56 | .page-header {
57 | color: #fff;
58 | text-align: center;
59 | background-color: #159957;
60 | background-image: linear-gradient(120deg, #155799, #159957); }
61 |
62 | @media screen and (min-width: 64em) {
63 | .page-header {
64 | padding: 5rem 6rem; } }
65 |
66 | @media screen and (min-width: 42em) and (max-width: 64em) {
67 | .page-header {
68 | padding: 3rem 4rem; } }
69 |
70 | @media screen and (max-width: 42em) {
71 | .page-header {
72 | padding: 2rem 1rem; } }
73 |
74 | .project-name {
75 | margin-top: 0;
76 | margin-bottom: 0.1rem; }
77 |
78 | @media screen and (min-width: 64em) {
79 | .project-name {
80 | font-size: 3.25rem; } }
81 |
82 | @media screen and (min-width: 42em) and (max-width: 64em) {
83 | .project-name {
84 | font-size: 2.25rem; } }
85 |
86 | @media screen and (max-width: 42em) {
87 | .project-name {
88 | font-size: 1.75rem; } }
89 |
90 | .project-tagline {
91 | margin-bottom: 2rem;
92 | font-weight: normal;
93 | opacity: 0.7; }
94 |
95 | @media screen and (min-width: 64em) {
96 | .project-tagline {
97 | font-size: 1.25rem; } }
98 |
99 | @media screen and (min-width: 42em) and (max-width: 64em) {
100 | .project-tagline {
101 | font-size: 1.15rem; } }
102 |
103 | @media screen and (max-width: 42em) {
104 | .project-tagline {
105 | font-size: 1rem; } }
106 |
107 | .main-content :first-child {
108 | margin-top: 0; }
109 | .main-content img {
110 | max-width: 100%; }
111 | .main-content h1, .main-content h2, .main-content h3, .main-content h4, .main-content h5, .main-content h6 {
112 | margin-top: 2rem;
113 | margin-bottom: 1rem;
114 | font-weight: normal;
115 | color: #159957; }
116 | .main-content p {
117 | margin-bottom: 1em; }
118 | .main-content code {
119 | padding: 2px 4px;
120 | font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
121 | font-size: 0.9rem;
122 | color: #383e41;
123 | background-color: #f3f6fa;
124 | border-radius: 0.3rem; }
125 | .main-content pre {
126 | padding: 0.8rem;
127 | margin-top: 0;
128 | margin-bottom: 1rem;
129 | font: 1rem Consolas, "Liberation Mono", Menlo, Courier, monospace;
130 | color: #567482;
131 | word-wrap: normal;
132 | background-color: #f3f6fa;
133 | border: solid 1px #dce6f0;
134 | border-radius: 0.3rem; }
135 | .main-content pre > code {
136 | padding: 0;
137 | margin: 0;
138 | font-size: 0.9rem;
139 | color: #567482;
140 | word-break: normal;
141 | white-space: pre;
142 | background: transparent;
143 | border: 0; }
144 | .main-content .highlight {
145 | margin-bottom: 1rem; }
146 | .main-content .highlight pre {
147 | margin-bottom: 0;
148 | word-break: normal; }
149 | .main-content .highlight pre, .main-content pre {
150 | padding: 0.8rem;
151 | overflow: auto;
152 | font-size: 0.9rem;
153 | line-height: 1.45;
154 | border-radius: 0.3rem; }
155 | .main-content pre code, .main-content pre tt {
156 | display: inline;
157 | max-width: initial;
158 | padding: 0;
159 | margin: 0;
160 | overflow: initial;
161 | line-height: inherit;
162 | word-wrap: normal;
163 | background-color: transparent;
164 | border: 0; }
165 | .main-content pre code:before, .main-content pre code:after, .main-content pre tt:before, .main-content pre tt:after {
166 | content: normal; }
167 | .main-content ul, .main-content ol {
168 | margin-top: 0; }
169 | .main-content blockquote {
170 | padding: 0 1rem;
171 | margin-left: 0;
172 | color: #819198;
173 | border-left: 0.3rem solid #dce6f0; }
174 | .main-content blockquote > :first-child {
175 | margin-top: 0; }
176 | .main-content blockquote > :last-child {
177 | margin-bottom: 0; }
178 | .main-content table {
179 | display: block;
180 | width: 100%;
181 | overflow: auto;
182 | word-break: normal;
183 | word-break: keep-all; }
184 | .main-content table th {
185 | font-weight: bold; }
186 | .main-content table th, .main-content table td {
187 | padding: 0.5rem 1rem;
188 | border: 1px solid #e9ebec; }
189 | .main-content dl {
190 | padding: 0; }
191 | .main-content dl dt {
192 | padding: 0;
193 | margin-top: 1rem;
194 | font-size: 1rem;
195 | font-weight: bold; }
196 | .main-content dl dd {
197 | padding: 0;
198 | margin-bottom: 1rem; }
199 | .main-content hr {
200 | height: 2px;
201 | padding: 0;
202 | margin: 1rem 0;
203 | background-color: #eff0f1;
204 | border: 0; }
205 |
206 | @media screen and (min-width: 64em) {
207 | .main-content {
208 | max-width: 64rem;
209 | padding: 2rem 6rem;
210 | margin: 0 auto;
211 | font-size: 1.1rem; } }
212 |
213 | @media screen and (min-width: 42em) and (max-width: 64em) {
214 | .main-content {
215 | padding: 2rem 4rem;
216 | font-size: 1.1rem; } }
217 |
218 | @media screen and (max-width: 42em) {
219 | .main-content {
220 | padding: 2rem 1rem;
221 | font-size: 1rem; } }
222 |
223 | .site-footer {
224 | padding-top: 2rem;
225 | margin-top: 2rem;
226 | border-top: solid 1px #eff0f1; }
227 |
228 | .site-footer-owner {
229 | display: block;
230 | font-weight: bold; }
231 |
232 | .site-footer-credits {
233 | color: #819198; }
234 |
235 | @media screen and (min-width: 64em) {
236 | .site-footer {
237 | font-size: 1rem; } }
238 |
239 | @media screen and (min-width: 42em) and (max-width: 64em) {
240 | .site-footer {
241 | font-size: 1rem; } }
242 |
243 | @media screen and (max-width: 42em) {
244 | .site-footer {
245 | font-size: 0.9rem; } }
246 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/GenBankExplorer/FeatureBin.java:
--------------------------------------------------------------------------------
1 | /**
2 | * A GenBankFile.FeatureBin stores a whole set of GenBankFile.Features, then returns vectors of them
3 | * on the basis of certain criteria. Since GenBankFile.Features contain all relevant information -
4 | * including the locus they belong to - they can be shifted around without hurting anything, and
5 | * anyways we're only making lists of pointers anyway.
6 | */
7 |
8 | /*
9 | *
10 | * GenBankExplorer
11 | * Copyright (C) 2007 Gaurav Vaidya
12 | *
13 | * This program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program; if not, write to the Free Software
25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 | *
27 | */
28 |
29 | package com.ggvaidya.TaxonDNA.GenBankExplorer;
30 |
31 | import com.ggvaidya.TaxonDNA.Common.*;
32 | import com.ggvaidya.TaxonDNA.Common.DNA.*;
33 | import java.util.*;
34 |
35 | public class FeatureBin {
36 | private List features = new LinkedList();
37 |
38 | public class FeatureList extends LinkedList implements SequenceContainer, Comparable {
39 | String name = null;
40 |
41 | public FeatureList(String name) {
42 | this.name = name;
43 | }
44 |
45 | public void addFeature(GenBankFile.Feature f) {
46 | add(f);
47 | }
48 |
49 | public void addFeatures(Collection c) {
50 | addAll(c);
51 | }
52 |
53 | public String getName() {
54 | return name;
55 | }
56 |
57 | public SequenceList getAsSequenceList() {
58 | return null;
59 | }
60 |
61 | public List alsoContains() {
62 | return this; // we contain ourselves
63 | }
64 |
65 | public String toString() {
66 | return getName();
67 | }
68 |
69 | public int compareTo(Object o) {
70 | return getName().compareTo(((FeatureList) o).getName());
71 | }
72 | }
73 |
74 | public FeatureBin() {}
75 |
76 | public FeatureBin(Collection features) {
77 | addAll(features);
78 | }
79 |
80 | public FeatureBin(GenBankFile gbf) {
81 | Iterator i = gbf.getLoci().iterator();
82 | while (i.hasNext()) {
83 | GenBankFile.Locus l = (GenBankFile.Locus) i.next();
84 |
85 | Object o = l.getSection("FEATURES");
86 | if (o == null) // no 'FEATURES' section
87 | continue;
88 | if (GenBankFile.FeaturesSection.class.isAssignableFrom(o.getClass())) {
89 | // valid!
90 | GenBankFile.FeaturesSection sec = (GenBankFile.FeaturesSection) o;
91 |
92 | Iterator i2 = sec.getFeatures().iterator();
93 | while (i2.hasNext()) {
94 | GenBankFile.Feature f = (GenBankFile.Feature) i2.next();
95 |
96 | add(f);
97 | }
98 | }
99 | }
100 | }
101 |
102 | public void clear() {
103 | features = new LinkedList();
104 | }
105 |
106 | public void addAll(Collection c) {
107 | features.addAll(c);
108 | }
109 |
110 | public void add(GenBankFile.Feature f) {
111 | features.add(f);
112 | }
113 |
114 | private void addFeatureToHashtable(Hashtable ht, String name, GenBankFile.Feature f) {
115 | if (ht.get(name) != null) {
116 | FeatureList list = (FeatureList) ht.get(name);
117 | list.addFeature(f);
118 | } else {
119 | FeatureList list = new FeatureList("Features containing " + name);
120 | list.addFeature(f);
121 |
122 | ht.put(name, list);
123 | }
124 | }
125 |
126 | public List getGenes(DelayCallback delay) throws DelayAbortedException {
127 | Hashtable ht_genes = new Hashtable();
128 | FeatureList misc_genes = new FeatureList("Features without gene/product");
129 |
130 | if (delay != null) delay.begin();
131 |
132 | Iterator i = features.iterator();
133 | int x = 0;
134 | while (i.hasNext()) {
135 | if (delay != null) delay.delay(x, features.size());
136 | x++;
137 |
138 | GenBankFile.Feature f = (GenBankFile.Feature) i.next();
139 |
140 | List s = f.getValues("/gene");
141 | if (s != null) {
142 | Iterator i2 = s.iterator();
143 | while (i2.hasNext()) {
144 | addFeatureToHashtable(
145 | ht_genes, "gene " + ((String) i2.next()) + "-" + f.getName(), f);
146 | }
147 | } else {
148 | // no 'gene'? what about product?
149 | //
150 | s = f.getValues("/product");
151 | if (s != null) {
152 | Iterator i2 = s.iterator();
153 | while (i2.hasNext()) {
154 | addFeatureToHashtable(
155 | ht_genes, "product " + ((String) i2.next()) + "-" + f.getName(), f);
156 | }
157 | } else {
158 | misc_genes.addFeature(f);
159 | }
160 | }
161 | }
162 |
163 | Vector v = new Vector(ht_genes.keySet());
164 | Collections.sort(v);
165 |
166 | // TODO: Stop the insanity
167 | LinkedList ll = new LinkedList();
168 | i = v.iterator();
169 | x = 0;
170 | while (i.hasNext()) {
171 | if (delay != null) delay.delay(x, v.size());
172 | x++;
173 | String gene = (String) i.next();
174 |
175 | ll.add(ht_genes.get(gene));
176 | }
177 |
178 | Collections.sort(ll);
179 | ll.add(misc_genes);
180 |
181 | if (delay != null) delay.end();
182 |
183 | return ll;
184 | }
185 |
186 | public FeatureList getByGene(String gene) {
187 | boolean nullSearch = false;
188 | FeatureList fs = new FeatureList("Features containing " + gene);
189 |
190 | if (gene.equals("No gene specified")) {
191 | nullSearch = true;
192 | fs = new FeatureList("No gene specified");
193 | }
194 |
195 | Iterator i = features.iterator();
196 | while (i.hasNext()) {
197 | GenBankFile.Feature f = (GenBankFile.Feature) i.next();
198 |
199 | List s = f.getValues("/gene");
200 | if (s != null) {
201 | if (s.contains(gene)) fs.addFeature(f);
202 | } else if (nullSearch) {
203 | fs.addFeature(f);
204 | }
205 | }
206 |
207 | Collections.sort(fs);
208 | return fs;
209 | }
210 | }
211 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/GenBankExplorer/DisplayMode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The DisplayMode (as in SequenceMatrix) is the 'view' of our MVC layout. All true DisplayModes
3 | * inherit from DisplayMode, and remember to call their parents in DisplayMode (unless they really
4 | * know what they're doing).
5 | */
6 |
7 | /*
8 | *
9 | * GenBankExplorer
10 | * Copyright (C) 2007 Gaurav Vaidya
11 | *
12 | * This program is free software; you can redistribute it and/or modify
13 | * it under the terms of the GNU General Public License as published by
14 | * the Free Software Foundation; either version 2 of the License, or
15 | * (at your option) any later version.
16 | *
17 | * This program is distributed in the hope that it will be useful,
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | * GNU General Public License for more details.
21 | *
22 | * You should have received a copy of the GNU General Public License
23 | * along with this program; if not, write to the Free Software
24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 | *
26 | */
27 |
28 | package com.ggvaidya.TaxonDNA.GenBankExplorer;
29 |
30 | import java.util.*;
31 | import javax.swing.event.*;
32 | import javax.swing.tree.*;
33 |
34 | public abstract class DisplayMode implements TreeModel, TreeSelectionListener {
35 | protected ViewManager viewManager = null; // the ViewManager object
36 | protected GenBankFile genBankFile = null; // the GenBankFile object
37 |
38 | // Internal information
39 | private Vector treeListeners = new Vector();
40 |
41 | // constructors
42 | public DisplayMode(ViewManager man) {
43 | viewManager = man;
44 | }
45 |
46 | // interfacings
47 | public void setGenBankFile(GenBankFile gbf) {
48 | this.genBankFile = gbf;
49 | }
50 |
51 | public void activateMode() {
52 | viewManager.getTree().setModel(this);
53 | viewManager.getTree().addTreeSelectionListener(this);
54 | }
55 |
56 | public void deactivateMode() {
57 | // can't just get rid of tree model like that
58 | viewManager.getTree().removeTreeSelectionListener(this);
59 | }
60 |
61 | // TREE MODEL CODE
62 | //
63 | public void addTreeModelListener(TreeModelListener l) {
64 | treeListeners.add(l);
65 | }
66 |
67 | public void removeTreeModelListener(TreeModelListener l) {
68 | treeListeners.remove(l);
69 | }
70 |
71 | /**
72 | * Fires a tree event at all listening TreeModelListeners. Warning: this will ONLY fire the
73 | * event as a treeStructureChanged(TreeModelEvent). If you need a less powerful event to be
74 | * fired, err ... update this code?
75 | */
76 | private void fireTreeEvent(TreeModelEvent e) {
77 | Iterator i = treeListeners.iterator();
78 | while (i.hasNext()) {
79 | TreeModelListener l = (TreeModelListener) i.next();
80 |
81 | l.treeStructureChanged(e);
82 | }
83 | }
84 |
85 | // Here is where we get an abstract 'tree' model out of the current
86 | // DisplayMode, and convert it into the root-index format so much
87 | // in vogue amongst TreeModels these days.
88 | //
89 | // The current plan is to have a single, overloadable function
90 | // which is:
91 | protected abstract java.util.List getSubnodes(Object node);
92 |
93 | // Calling getSubnodes() will return a List of
94 | // all the sub-objects of node, in the order required. It can
95 | // also return 'null' to indicate that it's on a node.
96 | //
97 | // The ONLY requirement is that you cannot have duplicate objects
98 | // in the tree ANYWHERE. If node1.equals(node2) is true, node1 and
99 | // node2 CANNOT BE IN THE SAME TREE. Kapish?
100 | //
101 | // Of course, we need to start somewhere, so you'll also have to
102 | // define:
103 | public abstract Object getRoot();
104 |
105 | //
106 | // And that's it!
107 | //
108 | // Now, here is the complexity we are sweeping under the metaphorical
109 | // carpet.
110 | //
111 | private Hashtable subNodes = null; // Object -> Vector
112 |
113 | private void updateHashtable() {
114 | subNodes = new Hashtable(); // clear our the hash!
115 |
116 | Object root = getRoot();
117 | addAllSubnodes(root);
118 | }
119 |
120 | // WARNING: do NOT use unless you know what you're doing!
121 | private void addAllSubnodes(Object node) {
122 | java.util.List currentSubnodes = getSubnodes(node);
123 | if (currentSubnodes == null) return;
124 |
125 | if (subNodes.get(node) != null) {
126 | // TODO: Better error, pls
127 | throw new RuntimeException("Duplicate object '" + node + "' found in tree!");
128 | }
129 |
130 | Vector v = new Vector();
131 | Iterator i = currentSubnodes.iterator();
132 | while (i.hasNext()) {
133 | Object o = (Object) i.next();
134 |
135 | v.add(o);
136 | subNodes.put(node, v); // replacing the previous 'v'
137 | addAllSubnodes(o);
138 | }
139 |
140 | subNodes.put(node, v);
141 | }
142 |
143 | public Object getChild(Object parent, int index) {
144 | Vector v = (Vector) subNodes.get(parent);
145 |
146 | if (v == null) return null;
147 |
148 | return v.get(index);
149 | }
150 |
151 | public int getChildCount(Object parent) {
152 | Vector v = (Vector) subNodes.get(parent);
153 |
154 | if (v == null) return 0;
155 |
156 | return v.size();
157 | }
158 |
159 | public int getIndexOfChild(Object parent, Object child) {
160 | Vector v = (Vector) subNodes.get(parent);
161 |
162 | if (v == null) return -1;
163 |
164 | return v.indexOf(child);
165 | }
166 |
167 | public boolean isLeaf(Object node) {
168 | if (genBankFile == null) return true;
169 |
170 | Vector v = (Vector) subNodes.get(node);
171 |
172 | if (v == null) return true;
173 |
174 | return false;
175 | }
176 |
177 | public void valueForPathChanged(TreePath path, Object newValue) {
178 | // hmmm!
179 | }
180 |
181 | // UPDATEs
182 | public void updateTree() {
183 | updateHashtable();
184 | fireTreeEvent(new TreeModelEvent(viewManager.getTree(), new TreePath(getRoot())));
185 | }
186 |
187 | public void updateNode(TreePath path) {
188 | if (path.getLastPathComponent().equals(getRoot())) updateHashtable();
189 | fireTreeEvent(new TreeModelEvent(viewManager.getTree(), path));
190 | }
191 |
192 | // TREE SELECTION LISTENER
193 | // The tree selection listener handles the nitty gritty of a TreeSelectionEvent.
194 | // If you don't need nitty-gritty-handling, you can directly overload:
195 | public void valueChanged(TreeSelectionEvent e) {
196 | TreePath[] treePaths = e.getPaths();
197 |
198 | for (int x = 0; x < treePaths.length; x++) {
199 | TreePath t = treePaths[x];
200 |
201 | if (e.isAddedPath(x)) pathSelected(t);
202 | else pathRemoved(t);
203 | }
204 | }
205 |
206 | public void pathSelected(TreePath t) {}
207 |
208 | public void pathRemoved(TreePath t) {}
209 | }
210 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/SpeciesIdentifier/ExportBySpeciesName.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Allows you provide a list of species names, and all sequences with that species name is exported
3 | * into a separate file.
4 | *
5 | * @author Gaurav Vaidya, gaurav@ggvaidya.com
6 | */
7 |
8 | /*
9 | TaxonDNA
10 | Copyright (C) 2008 Gaurav Vaidya
11 |
12 | This program is free software; you can redistribute it and/or modify
13 | it under the terms of the GNU General Public License as published by
14 | the Free Software Foundation; either version 2 of the License, or
15 | (at your option) any later version.
16 |
17 | This program is distributed in the hope that it will be useful,
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | GNU General Public License for more details.
21 |
22 | You should have received a copy of the GNU General Public License
23 | along with this program; if not, write to the Free Software
24 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 | */
26 |
27 | package com.ggvaidya.TaxonDNA.SpeciesIdentifier;
28 |
29 | import com.ggvaidya.TaxonDNA.Common.DNA.*;
30 | import com.ggvaidya.TaxonDNA.Common.UI.*;
31 | import java.awt.*;
32 | import java.awt.datatransfer.*;
33 | import java.awt.event.*;
34 | import java.io.*; // For the BufferedReader, mostly
35 | import java.util.*;
36 |
37 | public class ExportBySpeciesName extends Panel implements UIExtension, ActionListener {
38 | private SpeciesIdentifier seqId = null;
39 |
40 | // This is where we'll get our species list.
41 | private TextArea text_main = new TextArea();
42 |
43 | private Button btn_Calculate = new Button("Export sequences with the following species names");
44 | private Button btn_Copy;
45 |
46 | public ExportBySpeciesName(SpeciesIdentifier seqId) {
47 | this.seqId = seqId;
48 |
49 | setLayout(new BorderLayout());
50 |
51 | Panel top = new Panel();
52 | RightLayout rl = new RightLayout(top);
53 | top.setLayout(rl);
54 |
55 | btn_Calculate.addActionListener(this);
56 | rl.add(btn_Calculate, RightLayout.NEXTLINE | RightLayout.FILL_4);
57 |
58 | add(top, BorderLayout.NORTH);
59 |
60 | add(text_main);
61 |
62 | text_main.setText("Enter species list here");
63 |
64 | Panel buttons = new Panel();
65 | buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
66 |
67 | btn_Copy = new Button("Copy to Clipboard");
68 | btn_Copy.addActionListener(this);
69 | buttons.add(btn_Copy);
70 |
71 | add(buttons, BorderLayout.SOUTH);
72 | }
73 |
74 | public void actionPerformed(ActionEvent e) {
75 | String cmd = e.getActionCommand();
76 |
77 | if (cmd.equals("Copy to Clipboard") || cmd.equals("Oops, try again?")) {
78 | try {
79 | Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
80 | StringSelection selection = new StringSelection(text_main.getText());
81 |
82 | clip.setContents(selection, selection);
83 | } catch (IllegalStateException ex) {
84 | btn_Copy.setLabel("Oops, try again?");
85 | }
86 | btn_Copy.setLabel("Copy to Clipboard");
87 | }
88 |
89 | if (e.getSource().equals(btn_Calculate)) {
90 | exportSequences();
91 | }
92 | }
93 |
94 | public void exportSequences() {
95 | // Step 1. Make a list of 'chosen' species
96 | SequenceList list = seqId.lockSequenceList();
97 | try {
98 | String line;
99 | Vector vec_species_names = new Vector();
100 |
101 | // Read the names off text_main
102 | BufferedReader reader = new BufferedReader(new StringReader(text_main.getText()));
103 | while ((line = reader.readLine()) != null) {
104 | line = line.trim();
105 | if (line.isEmpty()) {
106 | // blank line, ignore
107 | } else {
108 | vec_species_names.add(line);
109 | }
110 | }
111 |
112 | int[] sequence_counts = new int[vec_species_names.size()];
113 |
114 | // Go through the sequence list
115 | SequenceList to_export = new SequenceList();
116 |
117 | Iterator i = list.iterator();
118 | while (i.hasNext()) {
119 | Sequence seq = (Sequence) i.next();
120 |
121 | Iterator i_names = vec_species_names.iterator();
122 | int x = 0;
123 | while (i_names.hasNext()) {
124 | String name = (String) i_names.next();
125 |
126 | if (seq.getSpeciesName().equalsIgnoreCase(name)) {
127 | // match!
128 | to_export.add(seq);
129 | sequence_counts[x]++;
130 | break;
131 | }
132 | x++;
133 | }
134 | }
135 |
136 | // Now: export!
137 | FileDialog fd =
138 | new FileDialog(
139 | seqId.getFrame(),
140 | "Where would you like me to extract "
141 | + to_export.count()
142 | + " sequences as FASTA?",
143 | FileDialog.SAVE);
144 | fd.setVisible(true);
145 |
146 | File f_output;
147 | if (fd.getFile() == null) {
148 | // cancel
149 | return;
150 | }
151 |
152 | // go for it!
153 | if (fd.getDirectory() != null) f_output = new File(fd.getDirectory(), fd.getFile());
154 | else f_output = new File(fd.getFile());
155 |
156 | // export
157 | com.ggvaidya.TaxonDNA.Common.DNA.formats.FastaFile ff =
158 | new com.ggvaidya.TaxonDNA.Common.DNA.formats.FastaFile();
159 | ff.writeFile(f_output, to_export, null);
160 |
161 | // yay done!
162 | // write out stuff to tell the user what happened, etc.
163 | StringBuilder results = new StringBuilder();
164 | results.append("Export successful!\n\n");
165 |
166 | i = vec_species_names.iterator();
167 | int x = 0;
168 | while (i.hasNext()) {
169 | String name = (String) i.next();
170 |
171 | results.append("\t" + name + "\t" + sequence_counts[x] + "\tsequences exported.\n");
172 | x++;
173 | }
174 |
175 | text_main.setText(results.toString());
176 | } catch (Exception e) {
177 | new MessageBox(
178 | seqId.getFrame(),
179 | "Error: could not export sequences!",
180 | "There was a problem exporting sequences. The technical description is: "
181 | + e.getMessage());
182 | } finally {
183 | seqId.unlockSequenceList();
184 | }
185 | }
186 |
187 | // DataChanged()? Not like we care.
188 | public void dataChanged() {
189 | return;
190 | }
191 |
192 | public String getShortName() {
193 | return "Export by Species Name";
194 | }
195 |
196 | public String getDescription() {
197 | return "Allows you to export species by species name";
198 | }
199 |
200 | public boolean addCommandsToMenu(Menu commandMenu) {
201 | return false;
202 | }
203 |
204 | public Panel getPanel() {
205 | return this;
206 | }
207 | }
208 |
--------------------------------------------------------------------------------
/src/main/java/com/ggvaidya/TaxonDNA/SequenceMatrix/Preferences.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Preferences is a common store for preferences. 'Preferences' preferences are stored into the
3 | * java.util.prefs store, and are thus persistant across sessions (heh heh - ain't I the software
4 | * engineer!). Everybody can check with us through a generic preferences system
5 | * (getPreference/setPreference), as well as to check some of the variables we ourselves maintain.
6 | *
7 | *
Some behaviour (and the underlying behaviour) we control ourselves; this includes: 1. The
8 | * *first* time a file is loaded, we pop up a dialog to check whether the user wants to use species
9 | * names or sequence names. We then save this setting for the entire session, but do NOT save it to
10 | * the prefs store; so it needs to be set once a session.
11 | *
12 | *
I suppose ideally, we ought to reset it when the all columns are cleared, but that's kind of
13 | * complicated. But we'll think about it in the future!
14 | */
15 |
16 | /*
17 | *
18 | * SequenceMatrix
19 | * Copyright (C) 2006, 2009 Gaurav Vaidya
20 | *
21 | * This program is free software; you can redistribute it and/or modify
22 | * it under the terms of the GNU General Public License as published by
23 | * the Free Software Foundation; either version 2 of the License, or
24 | * (at your option) any later version.
25 | *
26 | * This program is distributed in the hope that it will be useful,
27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 | * GNU General Public License for more details.
30 | *
31 | * You should have received a copy of the GNU General Public License
32 | * along with this program; if not, write to the Free Software
33 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 | *
35 | */
36 |
37 | package com.ggvaidya.TaxonDNA.SequenceMatrix;
38 |
39 | import com.ggvaidya.TaxonDNA.Common.UI.*;
40 | import java.awt.*;
41 | import java.awt.event.*;
42 |
43 | public class Preferences implements ActionListener {
44 | private SequenceMatrix matrix = null; // the SequenceMatrix object
45 |
46 | //
47 | // Options: note that we don't actually store these anymore; we're just a
48 | // proxy for the java.util.prefs interface
49 | //
50 |
51 | // How should Nexus output be formatted?
52 | //
53 | /** Nexus output should be interleaved. Returned by getNexusOutput(). */
54 | public static final int PREF_NEXUS_INTERLEAVED = 3;
55 |
56 | /** Nexus output should be in blocks. Returned by getNexusOutput(). */
57 | public static final int PREF_NEXUS_BLOCKS = 1;
58 |
59 | /** Nexus output should be in single, long lines. Returned by getNexusOutput(). */
60 | public static final int PREF_NEXUS_SINGLE_LINE = 2;
61 |
62 | /**
63 | * "Naked" Nexus: Nexus without anything but the core data. Please 'OR' this with a valid
64 | * getNexusOutput() format so everything stays just the way it is.
65 | */
66 | public static final int PREF_NEXUS_NAKED_FORMAT = 4;
67 |
68 | // Should we use the full name or the species name?
69 | //
70 | public static final int PREF_NOT_SET_YET = -1;
71 | public static final int PREF_USE_FULL_NAME = 0;
72 | public static final int PREF_USE_SPECIES_NAME = 1;
73 | private static int prefName = PREF_NOT_SET_YET;
74 |
75 | /** Constructor. Sets up the UI (on the dialog object, which isn't madeVisible just yet) and */
76 | public Preferences(SequenceMatrix matrix) {
77 | // set up the SequenceMatrix
78 | this.matrix = matrix;
79 | }
80 |
81 | //
82 | // the general Preference functions
83 | //
84 | /** Sets the preference specified */
85 | public void setPreference(String key, String value) {
86 | java.util.prefs.Preferences.userNodeForPackage(getClass()).put(key, value);
87 | }
88 |
89 | /**
90 | * Returns the preference specified
91 | *
92 | * @param def default value for this key
93 | */
94 | public String getPreference(String key, String def) {
95 | return java.util.prefs.Preferences.userNodeForPackage(getClass()).get(key, def);
96 | }
97 |
98 | /** Sets the preference specified (as int) */
99 | public void setPreference(String key, int value) {
100 | java.util.prefs.Preferences.userNodeForPackage(getClass()).putInt(key, value);
101 | }
102 |
103 | /**
104 | * Returns the preference specified (as int). You *have* to specify a min and max so we don't
105 | * have a problem with returning an out-of-range value when the program's defaults change.
106 | *
107 | * @param def default value for this key
108 | * @param min the lowest possible value for this option
109 | * @param max the highest possible value for this option
110 | */
111 | public int getPreference(String key, int def, int min, int max) {
112 | int result = java.util.prefs.Preferences.userNodeForPackage(getClass()).getInt(key, def);
113 | if (result < min || result > max) return def;
114 | return result;
115 | }
116 |
117 | /**
118 | * Returns either PREF_USE_FULL_NAME or PREF_USE_SPECIES_NAME
119 | *
120 | * @deprecated FileManager is handling this. Why are you?
121 | */
122 | public int getUseWhichName() {
123 | if (prefName == PREF_NOT_SET_YET) {
124 | Dialog dg =
125 | new Dialog(
126 | matrix.getFrame(), "Species names or sequence names?", true); // modal!
127 | dg.setLayout(new BorderLayout());
128 |
129 | TextArea ta = new TextArea("", 4, 40, TextArea.SCROLLBARS_VERTICAL_ONLY);
130 | ta.setEditable(false);
131 | ta.setText(
132 | "Would you like to use the full sequence name? I could also try to determine"
133 | + " the species name from the sequence name, and use that instead.");
134 | dg.add(ta);
135 |
136 | Panel buttons = new Panel();
137 | buttons.setLayout(new FlowLayout(FlowLayout.CENTER));
138 | Button btn = new Button("Use sequence names");
139 | btn.addActionListener(this);
140 | buttons.add(btn);
141 |
142 | btn = new Button("Use species names");
143 | btn.addActionListener(this);
144 | buttons.add(btn);
145 | dg.add(buttons, BorderLayout.SOUTH);
146 |
147 | dg.pack();
148 | dg.setVisible(true);
149 |
150 | // you are not going to believe this:
151 | // 1. The actionPerformed code will set prefName for us.
152 | // It will then close the dialog, at which point code
153 | // will continue executing. We will then return the
154 | // prefName to the system.
155 | //
156 | // Sigh.
157 | //
158 | return prefName;
159 | } else return prefName;
160 | }
161 |
162 | /** Handles Action events (such as the 'OK' button). */
163 | public void actionPerformed(ActionEvent e) {
164 | boolean close_parent_dialog = false;
165 |
166 | Object src = e.getSource();
167 |
168 | if (e.getActionCommand().equals("Use sequence names")) {
169 | prefName = PREF_USE_FULL_NAME;
170 | close_parent_dialog = true;
171 |
172 | } else if (e.getActionCommand().equals("Use species names")) {
173 | prefName = PREF_USE_SPECIES_NAME;
174 | close_parent_dialog = true;
175 | }
176 |
177 | if (close_parent_dialog) {
178 | Button btn = (Button) src;
179 | Panel p = (Panel) btn.getParent();
180 | Dialog dg = (Dialog) p.getParent();
181 |
182 | dg.setVisible(false);
183 | }
184 | }
185 |
186 | public void beginNewSession() {
187 | // clear all session-based variables
188 | // right now, this is only PREF_NOT_SET_YET.
189 | prefName = PREF_NOT_SET_YET;
190 | MessageBox.resetSession(); // reset all MB_YESNOTOALL
191 | }
192 | }
193 |
--------------------------------------------------------------------------------