[med-svn] [Git][med-team/jebl2][upstream] New upstream version 0.1+git20180418.653eb83
Andreas Tille
gitlab at salsa.debian.org
Thu Jul 5 12:41:30 BST 2018
Andreas Tille pushed to branch upstream at Debian Med / jebl2
Commits:
26097f2f by Andreas Tille at 2018-07-05T12:14:18+02:00
New upstream version 0.1+git20180418.653eb83
- - - - -
8 changed files:
- build.xml
- − 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>
=====================================
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/commit/26097f2fc3174ef02f67d6625acf126203e196e6
--
View it on GitLab: https://salsa.debian.org/med-team/jebl2/commit/26097f2fc3174ef02f67d6625acf126203e196e6
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/aea292be/attachment-0001.html>
More information about the debian-med-commit
mailing list