Skip to content

Commit

Permalink
Merge branch 'hotfix/v1.7.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
dbolotin committed Jun 20, 2016
2 parents 806761f + b4b5fae commit e031639
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 24 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@

MiXCR 1.7.4 (20 Jun 2016)
========================

-- Better compatibility with highly-paralelized execution of MiXCR on clusters: "more random"
generation of random temp file names
-- Human-readable messages for two wrong input cases
-- NPE fixed in case of align with `VGene`, assemble `VTranscript`
-- Minor fix for documentation


MiXCR 1.7.3 (17 May 2016)
========================

Expand Down
2 changes: 1 addition & 1 deletion doc/export.rst
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ One can also export all read IDs that were aggregated by eah clone. For this one

::

mixcr exportAlignments -p min -readIds index_file clones.clns clones.txt
mixcr exportClones -p min -readIds index_file clones.clns clones.txt

This will add a column with full enumeration of all reads that were absorbed by particular clone:

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<groupId>com.milaboratory</groupId>
<artifactId>mixcr</artifactId>
<version>1.7.3</version>
<version>1.7.4</version>
<packaging>jar</packaging>
<name>MiXCR</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.mapdb.DBMaker;

import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.NavigableSet;
Expand All @@ -46,9 +47,20 @@ public ActionParameters params() {

@Override
public void go(ActionHelper helper) throws Exception {
DB db = DBMaker.newFileDB(new File(parameters.getMapDBFile()))
.transactionDisable()
.make();
if (!originalReadsPresent()) {
final String msg = "Error: original reads was not saved in the .vdjca file: re-run align with '-g' option.";
throw new IllegalArgumentException(msg);
}

DB db;
try {
db = DBMaker.newFileDB(new File(parameters.getMapDBFile()))
.transactionDisable()
.make();
} catch (Exception | Error e) {
final String msg = "Error: corrupted or malformed index file.";
throw new IllegalArgumentException(msg, e);
}

int[] cloneIds = parameters.getCloneIds();
if (cloneIds.length == 1) {//byClones
Expand All @@ -62,6 +74,14 @@ public void go(ActionHelper helper) throws Exception {
db.close();
}

private boolean originalReadsPresent() throws IOException {
try (VDJCAlignmentsReader reader
= new VDJCAlignmentsReader(parameters.getVDJCAFile(), LociLibraryManager.getDefault())) {
VDJCAlignments test = reader.take();
return test == null || test.getOriginalSequences() != null;
}
}

public void writeMany(NavigableSet<ReadToCloneMapping> byAlignments, int[] clonIds)
throws Exception {
TIntObjectHashMap<SequenceWriter> writers = new TIntObjectHashMap<>(clonIds.length);
Expand Down Expand Up @@ -93,7 +113,6 @@ public void writeMany(NavigableSet<ReadToCloneMapping> byAlignments, int[] clonI
writer.write(createRead(vdjca.getOriginalSequences(), vdjca.getDescriptions()));
}

//todo create empty file!!!!!!!!!!!!!!!!!!!!
for (SequenceWriter writer : writers.valueCollection())
if (writer != null)
writer.close();
Expand All @@ -108,7 +127,7 @@ public void writeSingle(NavigableSet<ReadToCloneMapping> byClones, int cloneId)
new ReadToCloneMapping(Long.MAX_VALUE, 0, cloneId, false, false), true);

if (selected.isEmpty())
return;//todo create empty file!!!!!!!!!!!!!!!!!!!!
return;
try (VDJCAlignmentsReader reader = new VDJCAlignmentsReader(parameters.getVDJCAFile(),
LociLibraryManager.getDefault())) {

Expand Down Expand Up @@ -147,9 +166,21 @@ private static String createFileName(String fileName, int id) {
private static SequenceRead createRead(NSequenceWithQuality[] nseqs, String[] descr) {
if (nseqs.length == 1)
return new SingleReadImpl(-1, nseqs[0], descr[0]);
else return new PairedRead(
new SingleReadImpl(-1, nseqs[0], descr[0]),
new SingleReadImpl(-1, nseqs[1], descr[1]));
else {
String descr1, descr2;
if (descr == null)
descr1 = descr2 = "";
else if (descr.length == 1)
descr1 = descr2 = descr[0];
else {
descr1 = descr[0];
descr2 = descr[1];
}

return new PairedRead(
new SingleReadImpl(-1, nseqs[0], descr1),
new SingleReadImpl(-1, nseqs[1], descr2));
}
}

private static SequenceWriter createWriter(boolean paired, String fileName)
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/milaboratory/mixcr/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@
package com.milaboratory.mixcr.cli;

import com.milaboratory.mitools.cli.JCommanderBasedMain;
import com.milaboratory.mixcr.util.TempFileManager;
import com.milaboratory.mixcr.util.VersionInfoProvider;

import java.security.SecureRandom;
import java.util.Arrays;

public class Main {
public static void main(String... args) throws Exception {
TempFileManager.seed(Arrays.hashCode(args) + 17 * (new SecureRandom()).nextLong());
// Getting command string if executed from script
String command = System.getProperty("mixcr.command", "java -jar mixcr.jar");

Expand Down
19 changes: 10 additions & 9 deletions src/main/java/com/milaboratory/mixcr/reference/GeneFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,21 +378,22 @@ public static GeneFeature intersection(GeneFeature gf1, GeneFeature gf2) {
if (c > 0) {
result.add(new ReferenceRange(maxBegin,
gf2.regions[rangePointer2].end));
if (rangePointer2 != gf2.regions.length - 1)
throw new IllegalArgumentException();
break;
if (rangePointer2 == gf2.regions.length - 1)
break;
++rangePointer2;
} else {
result.add(new ReferenceRange(maxBegin,
gf1.regions[rangePointer1].end));
if (rangePointer1 != gf1.regions.length - 1)
throw new IllegalArgumentException();
break;
if (rangePointer1 == gf1.regions.length - 1)
break;
++rangePointer1;
}
} else
} else {
result.add(new ReferenceRange(maxBegin, gf1.regions[rangePointer1].end));

++rangePointer1;
++rangePointer2;
++rangePointer1;
++rangePointer2;
}
}

return new GeneFeature(result.toArray(new ReferenceRange[result.size()]), true);
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/com/milaboratory/mixcr/util/TempFileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
*/
package com.milaboratory.mixcr.util;

import com.milaboratory.util.RandomUtil;
import org.apache.commons.math3.random.RandomDataGenerator;
import org.apache.commons.math3.random.Well44497b;

import java.io.File;
import java.io.IOException;
Expand All @@ -38,6 +39,14 @@
public class TempFileManager {
private static final AtomicBoolean initialized = new AtomicBoolean(false);
static final ConcurrentHashMap<String, File> createdFiles = new ConcurrentHashMap<>();
static final RandomDataGenerator randomGenerator = new RandomDataGenerator(new Well44497b());

public static void seed(long seed) {
synchronized (randomGenerator) {
randomGenerator.reSeed(seed);
}
}

//static final String tmpdir = getTmpDir();
//private static String getTmpDir() {
// String tmpdir = AccessController.doPrivileged(new GetPropertyAction("java.io.tmpdir"));
Expand All @@ -56,7 +65,9 @@ public static File getTempFile() {
String name;

do {
name = "mixcr_" + RandomUtil.getThreadLocalRandomData().nextHexString(40);
synchronized (randomGenerator) {
name = "mixcr_" + randomGenerator.nextHexString(40);
}
file = File.createTempFile(name, null);
} while (createdFiles.putIfAbsent(name, file) != null);
if (file.length() != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import java.util.*;

import static com.milaboratory.mixcr.reference.ReferencePoint.*;
import static com.milaboratory.mixcr.reference.GeneFeature.*;
import static org.junit.Assert.*;

Expand Down Expand Up @@ -285,7 +286,7 @@ public void testRandom1() {

@Test
public void testStatic() throws Exception {
assertEquals(JRegion, parse("JRegion"));
assertEquals(JRegion, GeneFeature.parse("JRegion"));
}

static final GeneFeature create(int... indexes) {
Expand Down Expand Up @@ -359,11 +360,11 @@ public void testContains1() throws Exception {
public void testEncode1() throws Exception {
Collection<GeneFeature> features = GeneFeature.getFeaturesByName().values();
for (GeneFeature feature : features)
assertEquals(feature, parse(encode(feature)));
assertEquals(feature, GeneFeature.parse(encode(feature)));
}

private static void assertEncode(String str) {
Assert.assertEquals(str.replace(" ", ""), encode(parse(str)).replace(" ", ""));
Assert.assertEquals(str.replace(" ", ""), encode(GeneFeature.parse(str)).replace(" ", ""));
}

@Ignore
Expand Down Expand Up @@ -414,4 +415,23 @@ public int compareTo(GFT o) {
return feature.getFirstPoint().compareTo(o.feature.getFirstPoint());
}
}

@Test
public void testIntersection15() throws Exception {
assertEquals(intersection(VTranscript, VGene), VTranscript);
}

@Test
public void testIntersection16() throws Exception {
assertEquals(
intersection(VTranscript, new GeneFeature(UTR5Begin.move(1), VEnd)),
new GeneFeature(new GeneFeature(UTR5Begin.move(1), L1End), new GeneFeature(L2Begin, VEnd)));
}

@Test
public void testIntersection17() throws Exception {
assertEquals(
intersection(new GeneFeature(new GeneFeature(UTR5Begin, L1End.move(-1)), new GeneFeature(L2Begin.move(-5), VEnd.move(1))), new GeneFeature(UTR5Begin.move(1), VEnd)),
new GeneFeature(new GeneFeature(UTR5Begin.move(1), L1End.move(-1)), new GeneFeature(L2Begin.move(-5), VEnd)));
}
}

0 comments on commit e031639

Please sign in to comment.