[med-svn] [Git][med-team/jebl2][master] 10 commits: Add watch file using mode=git

Andreas Tille gitlab at salsa.debian.org
Thu Jul 5 12:41:23 BST 2018


Andreas Tille pushed to branch master at Debian Med / jebl2


Commits:
335f0030 by Andreas Tille at 2018-07-05T12:14:00+02:00
Add watch file using mode=git

- - - - -
26097f2f by Andreas Tille at 2018-07-05T12:14:18+02:00
New upstream version 0.1+git20180418.653eb83
- - - - -
5f61baf1 by Andreas Tille at 2018-07-05T12:14:18+02:00
Update upstream source from tag 'upstream/0.1+git20180418.653eb83'

Update to upstream version '0.1+git20180418.653eb83'
with Debian dir b5cbdac8aeeb9f12fbc6c2b6dd8890eb9fbc5f93
- - - - -
c74f048a by Andreas Tille at 2018-07-05T13:20:46+02:00
Refresh patches

- - - - -
acda5f84 by Andreas Tille at 2018-07-05T13:21:31+02:00
debhelper 11

- - - - -
acffcec5 by Andreas Tille at 2018-07-05T13:21:40+02:00
Point Vcs fields to salsa.debian.org

- - - - -
8eba3f02 by Andreas Tille at 2018-07-05T13:21:40+02:00
Standards-Version: 4.1.4

- - - - -
4bebfe90 by Andreas Tille at 2018-07-05T13:28:34+02:00
Remove now unneeded get-orig-source target

- - - - -
5eb85395 by Andreas Tille at 2018-07-05T13:32:31+02:00
Source / Target version 1.8 (instead of 1.6) since features of 8 are used

- - - - -
f1611fe5 by Andreas Tille at 2018-07-05T13:36:50+02:00
Upload to unstable

- - - - -


17 changed files:

- build.xml
- debian/changelog
- debian/compat
- debian/control
- − debian/get-orig-source
- − debian/patches/do_not_build_jam.patch
- debian/patches/series
- + debian/patches/source_8.patch
- debian/rules
- debian/watch
- − lib/jam-mac-only.jar
- src/jebl/evolution/io/NexusImporter.java
- src/jebl/evolution/sequences/AminoAcids.java
- src/jebl/evolution/sequences/Sequence.java
- src/jebl/evolution/sequences/TranslatedSequence.java
- src/jebl/evolution/sequences/Utils.java
- src/jebl/evolution/trees/RootedSubtree.java


Changes:

=====================================
build.xml
=====================================
--- a/build.xml
+++ b/build.xml
@@ -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>
 


=====================================
debian/changelog
=====================================
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,15 @@
+jebl2 (0.1+git20180418.653eb83-1) unstable; urgency=medium
+
+  * Add watch file using mode=git
+  * Remove now unneeded get-orig-source target
+  * debhelper 11
+  * Point Vcs fields to salsa.debian.org
+  * Standards-Version: 4.1.4
+  * Source / Target version 1.8 (instead of 1.6) since features of 8
+    are used
+
+ -- Andreas Tille <tille at debian.org>  Thu, 05 Jul 2018 13:32:40 +0200
+
 jebl2 (0.1+20140614-1) unstable; urgency=medium
 
   * New upstream Git checkout


=====================================
debian/compat
=====================================
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-9
+11


=====================================
debian/control
=====================================
--- a/debian/control
+++ b/debian/control
@@ -3,16 +3,16 @@ Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.
 Uploaders: Andreas Tille <tille at debian.org>
 Section: java
 Priority: optional
-Build-Depends: debhelper (>= 9),
+Build-Depends: debhelper (>= 11~),
                javahelper
 Build-Depends-Indep: default-jdk,
                      default-jdk-doc,
                      libtrove-java,
                      libtrove-java-doc,
                      ant
-Standards-Version: 3.9.6
-Vcs-Browser: https://anonscm.debian.org/cgit/debian-med/jebl2.git
-Vcs-Git: https://anonscm.debian.org/debian-med/jebl2.git
+Standards-Version: 4.1.4
+Vcs-Browser: https://salsa.debian.org/med-team/jebl2
+Vcs-Git: https://salsa.debian.org/med-team/jebl2.git
 Homepage: https://github.com/rambaut/jebl2
 
 Package: libjebl2-java


=====================================
debian/get-orig-source deleted
=====================================
--- a/debian/get-orig-source
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh -e
-
-COMPRESS=xz
-
-NAME=`dpkg-parsechangelog | awk '/^Source/ { print $2 }'`
-MVERSION=`dpkg-parsechangelog | awk '/^Version:/ { print $2 }' | sed 's/^\([0-9\.]\+\)[+~][-0-9]\+$/\1/'`
-
-mkdir -p ../tarballs
-cd ../tarballs
-# need to clean up the tarballs dir first because upstream tarball might
-# contain a directory with unpredictable name
-rm -rf *
-git clone --quiet https://github.com/rambaut/${NAME}.git
-cd ${NAME}
-VERSION=${MVERSION}+`date -d @$(git show --format="%at" | head -n1) +%Y%m%d`
-# for esthetical reasons set file timestamps (if git-restore-mtime is installed)
-git restore-mtime || true
-cd ..
-TARDIR=${NAME}-${VERSION}
-mv ${NAME} ${TARDIR}
-rm -rf ${TARDIR}/.git
-
-GZIP="--best --no-name" tar --owner=root --group=root --mode=a+rX -caf "$NAME"_"$VERSION".orig.tar.${COMPRESS} "${TARDIR}"
-rm -rf ${TARDIR}


=====================================
debian/patches/do_not_build_jam.patch deleted
=====================================
--- a/debian/patches/do_not_build_jam.patch
+++ /dev/null
@@ -1,103 +0,0 @@
-Author: Andreas Tille <tille at debian.org>
-Last-Update: Thu, 10 Feb 2011 10:26:38 +0100
-Description: Do not build jam
-
---- a/build.xml
-+++ b/build.xml
-@@ -7,7 +7,6 @@
-     <!-- 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"/>
-@@ -19,31 +18,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,38 +29,6 @@
- 
-     </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">
-@@ -105,7 +50,7 @@
-         </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}"/>
- 
-@@ -116,7 +61,7 @@
-         </jar>
-     </target>
- 
--    <target name="dist-clean" depends="clean,compile-jebl,compile-jam" description="generate the distribution">
-+    <target name="dist-clean" depends="clean,compile-jebl" 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


=====================================
debian/patches/series
=====================================
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,2 @@
 javadoc.patch
-do_not_build_jam.patch
+source_8.patch


=====================================
debian/patches/source_8.patch
=====================================
--- /dev/null
+++ b/debian/patches/source_8.patch
@@ -0,0 +1,15 @@
+Description: Source / Target version 1.8 (instead of 1.6) since features of 8 are used
+Author: Andreas Tille <tille at debian.org>
+Last-Update: Thu, 05 Jul 2018 12:08:56 +0200
+
+--- a/build.xml
++++ b/build.xml
+@@ -30,7 +30,7 @@
+ 
+     <target name="compile-jebl" depends="init">
+         <!-- Compile the java code from ${src} into ${build} -->
+-        <javac source="1.6" srcdir="${src}" destdir="${build}" debug="true" target="1.6">
++        <javac source="1.8" srcdir="${src}" destdir="${build}" debug="true" target="1.8">
+             <include name="jebl/**/*"/>
+         </javac>
+         <copy todir="${build}">


=====================================
debian/rules
=====================================
--- a/debian/rules
+++ b/debian/rules
@@ -12,6 +12,3 @@ override_dh_auto_clean:
 override_dh_auto_build:
 	dh_auto_build
 	ant -buildfile javadoc.xml
-
-get-orig-source:
-	. debian/get-orig-source


=====================================
debian/watch
=====================================
--- a/debian/watch
+++ b/debian/watch
@@ -1,2 +1,7 @@
-# Development of jebl2 moved to Git but upstream keeps the habit
-# not to tag releases so we can not create a proper d/watch file
\ No newline at end of file
+version=4
+
+opts="mode=git,pretty=0.1+git%cd.%h" \
+    https://github.com/rambaut/jebl2.git HEAD
+
+# Issue asking for release tags:
+# https://github.com/rambaut/jebl2/issues/5


=====================================
lib/jam-mac-only.jar deleted
=====================================
Binary files a/lib/jam-mac-only.jar and /dev/null differ


=====================================
src/jebl/evolution/io/NexusImporter.java
=====================================
--- a/src/jebl/evolution/io/NexusImporter.java
+++ b/src/jebl/evolution/io/NexusImporter.java
@@ -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("{")) {
-            // the value is a list so recursively parse the elements
-            // and return an array
-            String[] elements = value.substring(1, value.length() - 1).split(",");
+            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
+                elements = value.split(",");
+            }
             Object[] values = new Object[elements.length];
             for (int i = 0; i < elements.length; i++) {
                 values[i] = parseValue(elements[i]);


=====================================
src/jebl/evolution/sequences/AminoAcids.java
=====================================
--- a/src/jebl/evolution/sequences/AminoAcids.java
+++ b/src/jebl/evolution/sequences/AminoAcids.java
@@ -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.
 


=====================================
src/jebl/evolution/sequences/Sequence.java
=====================================
--- a/src/jebl/evolution/sequences/Sequence.java
+++ b/src/jebl/evolution/sequences/Sequence.java
@@ -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.
  *
@@ -21,20 +26,20 @@ import jebl.util.Attributable;
  */
 public interface Sequence extends Attributable, Comparable {
 
-    /**
-     * @return the taxon that this sequence represents (primarily used to match sequences with tree nodes)
-     */
-    Taxon getTaxon();
+	/**
+	 * @return the taxon that this sequence represents (primarily used to match sequences with tree nodes)
+	 */
+	Taxon getTaxon();
 
-    /**
-     * @return the type of symbols that this sequence is made up of.
-     */
-    SequenceType getSequenceType();
+	/**
+	 * @return the type of symbols that this sequence is made up of.
+	 */
+	SequenceType getSequenceType();
 
-    /**
-     * @return a string representing the sequence of symbols.
-     */
-    String getString();
+	/**
+	 * @return a string representing the sequence of symbols.
+	 */
+	String getString();
 
 	/**
 	 * @return an array of state objects.
@@ -46,14 +51,71 @@ public interface Sequence extends Attributable, Comparable {
 	 */
 	byte[] getStateIndices();
 
-    /**
-     * @return the state at site.
-     */
-    State getState(int site);
+	/**
+	 * @return the state at site.
+	 */
+	State getState(int site);
 
 	/**
 	 * Get the length of the sequence
 	 * @return the length
 	 */
-    int getLength();
+	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);
+
+	}
 }


=====================================
src/jebl/evolution/sequences/TranslatedSequence.java
=====================================
--- a/src/jebl/evolution/sequences/TranslatedSequence.java
+++ b/src/jebl/evolution/sequences/TranslatedSequence.java
@@ -1,20 +1,34 @@
 package jebl.evolution.sequences;
 
 /**
- * @author rambaut
- *         Date: Jul 27, 2005
- *         Time: 12:48:31 AM
+ * @author Andrew Rambaut
  */
 public class TranslatedSequence extends FilteredSequence {
 
+	/**
+	 * Create a TranslatedSequence from a source codon or nucleotide sequence
+	 * @param source
+	 * @param geneticCode
+	 */
 	public TranslatedSequence(Sequence source, GeneticCode geneticCode) {
+		this(source, geneticCode, 1);
+	}
+
+	/**
+	 * Create a TranslatedSequence from a source codon or nucleotide sequence
+	 * @param source
+	 * @param geneticCode
+	 * @param frame indexed from 1
+     */
+	public TranslatedSequence(Sequence source, GeneticCode geneticCode, int frame) {
 		super(source);
 
 		this.geneticCode = geneticCode;
+		this.frame = frame;
 	}
 
 	protected State[] filterSequence(Sequence source) {
-		return jebl.evolution.sequences.Utils.translate(source.getStates(), geneticCode);
+		return jebl.evolution.sequences.Utils.translate(source.getStates(), geneticCode, frame);
 	}
 
     /**
@@ -25,5 +39,6 @@ public class TranslatedSequence extends FilteredSequence {
     }
 
 	private final GeneticCode geneticCode;
+	private final int frame;
 
 }


=====================================
src/jebl/evolution/sequences/Utils.java
=====================================
--- a/src/jebl/evolution/sequences/Utils.java
+++ b/src/jebl/evolution/sequences/Utils.java
@@ -380,6 +380,28 @@ public class Utils {
     }
 
     /**
+     * Counts the number of stop codons in an amino acid sequence
+     * @param sequence the sequence string to count stop codons
+     * @return the number of stop codons
+     */
+    public static int getStopCodonCount(final Sequence sequence) {
+
+        if (sequence.getSequenceType() != SequenceType.AMINO_ACID) {
+            throw new IllegalArgumentException("Sequence should be an amino acid sequence");
+        }
+
+        int count = 0;
+        for (State state : sequence.getStates()) {
+            if (((AminoAcidState)state).isStop()) {
+                count ++;
+            }
+        }
+
+        return count;
+    }
+
+
+    /**
      * Produce a clean sequence filtered of spaces and digits.
      * @param seq the sequence
      * @param type the sequence type


=====================================
src/jebl/evolution/trees/RootedSubtree.java
=====================================
--- a/src/jebl/evolution/trees/RootedSubtree.java
+++ b/src/jebl/evolution/trees/RootedSubtree.java
@@ -54,6 +54,12 @@ final public class RootedSubtree implements RootedTree {
             }
             if (children.size() >= 2) {
                 newNode = createInternalNode(children);
+
+                for( Map.Entry<String, Object> e : node.getAttributeMap().entrySet() ) {
+                    newNode.setAttribute(e.getKey(), e.getValue());
+                }
+
+                setHeight(newNode, tree.getHeight(node));
             } else if (children.size() == 1) {
 
                 newNode = children.get(0);
@@ -63,17 +69,6 @@ final public class RootedSubtree implements RootedTree {
             }
         }
 
-        if (newNode != null) {
-//        final Map<String, Object> map = node.getAttributeMap();
-//        if( ! map.isEmpty() ) {
-            for( Map.Entry<String, Object> e : node.getAttributeMap().entrySet() ) {
-                newNode.setAttribute(e.getKey(), e.getValue());
-            }
-            // }
-            setHeight(newNode, tree.getHeight(node));
-        }
-
-
         return newNode;
     }
 



View it on GitLab: https://salsa.debian.org/med-team/jebl2/compare/8d274c4498a605d0b28a6f14f04e6141b3bdf868...f1611fe5fbf19ca25334d74779f78131c07bdca2

-- 
View it on GitLab: https://salsa.debian.org/med-team/jebl2/compare/8d274c4498a605d0b28a6f14f04e6141b3bdf868...f1611fe5fbf19ca25334d74779f78131c07bdca2
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20180705/dfe99afc/attachment-0001.html>


More information about the debian-med-commit mailing list