Commit 26097f2f authored by Andreas Tille's avatar Andreas Tille
Browse files

New upstream version 0.1+git20180418.653eb83

parent df201e45
Loading
Loading
Loading
Loading
+2 −74
Original line number Diff line number Diff line
@@ -7,9 +7,7 @@
    <!-- set global properties for this build -->
    <property name="src" location="src"/>
    <property name="build" location="build"/>
    <property name="build-mac-only" location="build-mac-only"/>

    <property name="lib" location="lib"/>
    <property name="dist" location="dist"/>

    <property environment="env"/>
@@ -19,31 +17,9 @@
        <tstamp/>
        <!-- Create the build directory structure used by compile -->
        <mkdir dir="${build}"/>
        <mkdir dir="${build-mac-only}"/>
        <mkdir dir="${dist}"/>
    </target>

    <target name="compile-jam" depends="init">
        <!-- Compile the java code from ${jamsrc} into ${build} -->

        <condition property="isMac">
            <os family="mac"/>
        </condition>
        <javac source="1.5" srcdir="${src}" target="1.5" destdir="${build}" debug="true">
            <include name="org/**/*"/>
            <exclude name="org/**/maconly/*" unless = "isMac"/>
        </javac>

        <!-- Utils.class was getting included in jebl.jar    -->
        <!-- twice and Pack200 was having issues.            -->
        <!-- Doesn't seem to be the case for me, the class is missing! RM-->
        <!--<delete file="${build}/org/virion/jam/mac/Utils.class"/>-->

        <copy todir="${build}">
            <fileset dir="${src}" includes="org/**/*.png"/>
        </copy>
    </target>

    <target name="clean">
        <mkdir dir="${build}"/>
        <delete includeEmptyDirs="true">
@@ -52,41 +28,9 @@

    </target>

    <target name="compile-jam-mac-only" depends="init">
        <!-- Compile the java code from ${jamsrc} into ${build} -->
        <condition property="isMac">
            <os family="mac"/>
        </condition>
        <javac source="1.5" srcdir="${src}" target="1.5" destdir="${build-mac-only}">
            <include name="org/**/maconly/*"/>
        </javac>
    </target>

    <target name="dist-jam-mac-only" depends="compile-jam-mac-only" description="generate the -mac-only distribution">
        <!-- Create the distribution directory -->
        <mkdir dir="${dist}"/>

        <!-- create the mac-only jar file -->
        <jar jarfile="${lib}/jam-mac-only.jar">
            <fileset dir="${build-mac-only}" includes="**/mac*/**/*.class,*.properties"/>
        </jar>
    </target>


    <target name="dist-jam" depends="compile-jam" description="generate the JAM distribution">
        <!-- Create the distribution directory -->
        <mkdir dir="${dist}"/>
        <delete file="${dist}/jam.jar"/>
        <!-- Put everything in ${build} into the jam.jar file -->
        <jar jarfile="${dist}/jam.jar">
            <fileset dir="${build}" includes="org/**/*.class,org/**/*.properties,org/**/*.png"/>
            <zipgroupfileset dir="${lib}" includes="jam-mac-only.jar"/>
        </jar>
    </target>

    <target name="compile-jebl" depends="init">
        <!-- Compile the java code from ${src} into ${build} -->
        <javac source="1.5" srcdir="${src}" destdir="${build}" debug="true" target="1.5">
        <javac source="1.6" srcdir="${src}" destdir="${build}" debug="true" target="1.6">
            <include name="jebl/**/*"/>
        </javac>
        <copy todir="${build}">
@@ -101,32 +45,16 @@
        <!-- Put everything in ${build} into the jebl-${DSTAMP}.jar file -->
        <jar jarfile="${dist}/jebl.jar">
            <fileset dir="${build}" includes="jebl/**/*.class,jebl/**/*.properties,jebl/**/*.png"/>
            <zipgroupfileset dir="${lib}" includes="**/*.jar"/>
        </jar>
    </target>

    <target name="dist" depends="dist-jebl,dist-jam" description="generate the distribution">
    <target name="dist" depends="dist-jebl" description="generate the distribution">
        <!-- Create the distribution directory -->
        <mkdir dir="${dist}"/>

        <!-- Put everything in ${build} into the jebl-${DSTAMP}.jar file -->
        <jar jarfile="${dist}/jebl.jar">
            <fileset dir="${build}" includes="**/*.class,**/*.properties,**/*.png"/>
            <zipgroupfileset dir="${lib}" includes="**/*.jar"/>
        </jar>
    </target>

    <target name="dist-clean" depends="clean,compile-jebl,compile-jam" description="generate the distribution">
        <!-- For some reason I don't fully understand, running the standard distribute
         script doesn't always work if you have done a previous build on a previous version
         of the source code. For some reason, it just doesn't compile some files. This
         script seems to work better.-->
        <mkdir dir="${dist}"/>

        <!-- Put everything in ${build} into the jebl-${DSTAMP}.jar file -->
        <jar jarfile="${dist}/jebl.jar">
            <fileset dir="${build}" includes="**/*.class,**/*.properties,**/*.png"/>
            <zipgroupfileset dir="${lib}" includes="**/*.jar"/>
        </jar>
    </target>

lib/jam-mac-only.jar

deleted100644 → 0
−1.73 KiB

File deleted.

+19 −4
Original line number Diff line number Diff line
@@ -1360,7 +1360,8 @@ public class NexusImporter implements AlignmentImporter, SequenceImporter, TreeI
        // value=number, value="string", value={item1, item2, item3}
        // (label must be quoted if it contains spaces (i.e. "my label"=label)

        Pattern pattern = Pattern.compile("(\"[^\"]*\"+|[^,=\\s]+)\\s*(=\\s*(\\{[^=}]*\\}|\"[^\"]*\"+|[^,]+))?");
//        Pattern pattern = Pattern.compile("(\"[^\"]*\"+|[^,=\\s]+)\\s*(=\\s*(\\{[^=}]*\\}|\"[^\"]*\"+|[^,]+))?");
        Pattern pattern = Pattern.compile("(\"[^\"]*\"+|[^,=\\s]+)\\s*(=\\s*(\\{(\\{[^\\}]+\\},?)+\\}|\\{[^\\}]+\\}|\"[^\"]*\"+|[^,]+))?");
        Matcher matcher = pattern.matcher(meta);

        while (matcher.find()) {
@@ -1397,9 +1398,23 @@ public class NexusImporter implements AlignmentImporter, SequenceImporter, TreeI
        value = value.trim();

        if (value.startsWith("{")) {
            value = value.substring(1, value.length() - 1);

            String[] elements;

            if (value.startsWith("{")) {
                // the value is a list of a list so recursively parse the elements
                // and return an array

                // need to match },{ but leave the brackets in place
                value = value.replaceAll("\\},\\{","}@,@{");
                elements = value.split("@,@");

            } else {
                // the value is a list so recursively parse the elements
                // and return an array
            String[] elements = value.substring(1, value.length() - 1).split(",");
                elements = value.split(",");
            }
            Object[] values = new Object[elements.length];
            for (int i = 0; i < elements.length; i++) {
                values[i] = parseValue(elements[i]);
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public final class AminoAcids {
    public static final AminoAcidState Z_STATE = new AminoAcidState("Glutamine or glutamic acid", "Glx", "Z", 23, new AminoAcidState[]{E_STATE, Q_STATE});
    public static final AminoAcidState J_STATE = new AminoAcidState("Leucine or Isoleucine", "Xle", "J", 24, new AminoAcidState[]{I_STATE, L_STATE});
    public static final AminoAcidState X_STATE = new AminoAcidState("Unknown amino acid", "Xaa", "X", 25, CANONICAL_STATES);
    public static final AminoAcidState UNKNOWN_STATE = new AminoAcidState("Unknown amino acid", "Xaa", "?", 26, CANONICAL_STATES);
    public static final AminoAcidState UNKNOWN_STATE = new AminoAcidState("Unknown amino acid", "Xaa", "X", 26, CANONICAL_STATES);
    public static final AminoAcidState STOP_STATE = new AminoAcidState("Stop codon", " * ","*", 27);
    public static final AminoAcidState GAP_STATE = new AminoAcidState("Gap",  " - ", "-", 28, CANONICAL_STATES); // This really shouldn't include the canonical states, but I'm scared changing it may break stuff.

+79 −17
Original line number Diff line number Diff line
@@ -11,6 +11,11 @@ package jebl.evolution.sequences;
import jebl.evolution.taxa.Taxon;
import jebl.util.Attributable;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
 * A biomolecular sequence.
 *
@@ -56,4 +61,61 @@ public interface Sequence extends Attributable, Comparable {
	 * @return the length
	 */
	int getLength();

	/**
	 * Append two sequences together to create a new sequence object. New sequence has the taxon of
	 * the first sequence.
	 * @param sequence1
	 * @param sequence2
	 * @return
	 */
	public static Sequence appendSequences(Sequence sequence1, Sequence sequence2) {
		if (sequence1.getSequenceType() != sequence2.getSequenceType()) {
			throw new IllegalArgumentException("sequences to be appended not of the same type");
		}
		State[] states = new State[sequence1.getLength() + sequence2.getLength()];
		System.arraycopy(sequence1.getStates(), 0, states, 0, sequence1.getLength());
		System.arraycopy(sequence2.getStates(), 0, states, sequence1.getLength(), sequence2.getLength());
		return new BasicSequence(sequence1.getSequenceType(), sequence1.getTaxon(), states);
	}

	/**
	 * Returns a sub-sequence for states from, to (inclusive).
	 * @param sequence
	 * @param from
	 * @param to
	 * @return
	 */
	public static Sequence getSubSequence(Sequence sequence, int from, int to) {
		if (from > to) {
			throw new IllegalArgumentException("subsequence from is greater than to");
		}
		if (from >= sequence.getLength() || to >= sequence.getLength()) {
			throw new IllegalArgumentException("subsequence range out of bounds");
		}
		State[] states = new State[to - from + 1];
		System.arraycopy(sequence.getStates(), from, states, 0, states.length);
		return new BasicSequence(sequence.getSequenceType(), sequence.getTaxon(), states);
	}

	public static Sequence trimSequence(Sequence sequence, State[] trimStates) {
		Set<State> trimSet = new HashSet<>(Arrays.asList(trimStates));
		State[] sourceStates = sequence.getStates();
		int i = 0;
		while (i < sourceStates.length && trimSet.contains(sourceStates[i])) {
			i++;
		}
		if (i == sourceStates.length) {
			return new BasicSequence(sequence.getSequenceType(), sequence.getTaxon(), new State[] {} );
		}

		Sequence sequence1 = getSubSequence(sequence, i, sourceStates.length - 1);
		sourceStates = sequence1.getStates();
		i = sourceStates.length - 1;
		while (i > 0 && trimSet.contains(sourceStates[i])) {
			i--;
		}
		return getSubSequence(sequence1, 0, i);

	}
}
Loading