Skip to content

Commit

Permalink
Merge branch 'hotfix/v1.7.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
dbolotin committed May 17, 2016
2 parents b10f2a0 + 3b9ddf0 commit 806761f
Show file tree
Hide file tree
Showing 11 changed files with 231 additions and 23 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@

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

-- Fixed: wrong boundaries of CDR1-CDR3 in Rat IGH/IGK references imported from IMGT
-- Fixed: bug leading to incorrect parsing of input/output file paths with spaces
-- Fixed: bug leading to incorrect parsing of input/output file paths with spaces
-- Automatic adjustment of featureToAlign in assemble action; fixes `NPE` in some use-cases of RNA
data analysis with IMGT reference
-- Added support for FreeBSD in mixcr script
-- minor: Human-readable error messages for illegal analysis options with IMGT reference
-- minor: Added human-readable error message for unknown species


MiXCR 1.7.2 ( 5 May 2016)
========================

Expand Down
4 changes: 2 additions & 2 deletions doc/export.rst
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ In any way, first one need to specify additonal option ``--index`` for the :ref:

mixcr assemble --index index_file alignments.vdjca output.clns

This will tell MiXCR to store mapping in the file ``index_file``. Now one can use ``index_file`` in order to access this information. For example using ``-cloneId`` option for ``exportAlignments`` command:
This will tell MiXCR to store mapping in the file ``index_file`` (actually two files will be created: ``index_file`` and ``index_file.p`` both of which are used to store the index; in further options one should specify only ``index_file`` without ``.p`` extension and MiXCR will automatically read both required files). Now one can use ``index_file`` in order to access this information. For example using ``-cloneId`` option for ``exportAlignments`` command:

::

Expand Down Expand Up @@ -663,7 +663,7 @@ Finally, one can export reads aggregated by each clone into separate ``.fastq``

mixcr align -g -l IGH input.fastq alignments.vdjca.gz

With this option MiXCR will store original reads in the ``.vdjca`` file. Then one can export reads corresponding for particular clone with ``exportReads`` command. For example, export all reads that were assembled into the first clone (clone with cloneId = 1):
With this option MiXCR will store original reads in the ``.vdjca`` file. Then one can export reads corresponding for particular clone with ``exportReads`` command. For example, export all reads that were assembled into the first clone (clone with cloneId = 0):

::

Expand Down
5 changes: 5 additions & 0 deletions importFromIMGT.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ do
# Workaround for *** IMGT malformed files
if [[ "$(echo ${species} | tr [:upper:] [:lower:])" == mus* ]] && [[ "$locus" == TR[AD] ]]; then
comm="$comm -p imgt_a1"
echo "Special paramenters for Mouse TRA/D genes activated."
fi
if [[ "$(echo ${species} | tr [:upper:] [:lower:])" == rat* ]] && [[ "$locus" == IG[HK] ]]; then
comm="$comm -p imgt_a2"
echo "Special paramenters for Rat IGH/K genes activated."
fi

# Output file info on the last iteration
Expand Down
11 changes: 9 additions & 2 deletions mixcr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

java="java"

Expand Down Expand Up @@ -52,6 +52,13 @@ case $os in
maxMb=$(($rFreeMb-$delta))
dir="$(dirname "$(readlink -f "$0")")"
;;
FreeBSD)
freeBlocks=$(vmstat -s | grep -E 'free$' | awk '{ print $1 }')
inactiveBlocks=$(vmstat -s | grep inactive | awk '{ print $1 }')
freeMb=$(( ($freeBlocks+$inactiveBlocks)*4096/1048576 ))
maxMb=$(($freeMb-$delta))
dir=$(dirname "$(readlinkUniversal "$0")")
;;
*)
echo "Unknown OS."
exit 1
Expand Down Expand Up @@ -87,7 +94,7 @@ do

;;
*)
mixcrArgs+=(${key})
mixcrArgs+=("${key}")
;;
esac
done
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.2</version>
<version>1.7.3</version>
<packaging>jar</packaging>
<name>MiXCR</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ public GeneFeature getFeatureToAlign(GeneType geneType) {
return params.getFeatureToAlign();
}

public CloneFactoryParameters setFeatureToAlign(GeneType geneType, GeneFeature feature) {
if (geneType == GeneType.Diversity)
if (dParameters == null)
throw new IllegalArgumentException("No D parameters.");
else
dParameters.setGeneFeatureToAlign(feature);
else {
VJCClonalAlignerParameters params = getVJCParameters(geneType);
if (params == null)
throw new IllegalArgumentException("No parameters for " + geneType + ".");
else
params.setFeatureToAlign(feature);
}
return this;
}

public CloneFactoryParameters setVJCParameters(GeneType geneType, VJCClonalAlignerParameters parameters) {
if (parameters == null)
vdcParameters.remove(geneType);
Expand Down
69 changes: 59 additions & 10 deletions src/main/java/com/milaboratory/mixcr/cli/ActionAlign.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ public void go(ActionHelper helper) throws Exception {

if (!actionParameters.overrides.isEmpty()) {
alignerParameters = JsonOverrider.override(alignerParameters, VDJCAlignerParameters.class, actionParameters.overrides);
if (alignerParameters == null)
if (alignerParameters == null) {
System.err.println("Failed to override some parameter.");
return;
}
}

VDJCAligner aligner = VDJCAligner.createAligner(alignerParameters,
Expand All @@ -87,19 +89,57 @@ public void go(ActionHelper helper) throws Exception {
return;
}

// Checking species
int speciesId = ll.getSpeciesTaxonId(actionParameters.species);

if (speciesId == -1)
speciesId = Species.fromString(actionParameters.species);

if (speciesId == -1) {
System.err.println("Can't find species with id: " + actionParameters.species);
return;
}

boolean warnings = false;

for (Locus locus : actionParameters.getLoci()) {
LocusContainer lc = ll.getLocus(actionParameters.species, locus);
LocusContainer lc = ll.getLocus(speciesId, locus);
if (lc == null) {
if (params().printWarnings())
if (params().printWarnings()) {
System.err.println("WARNING: No records for " + locus);
warnings = true;
}
continue;
}
for (Allele allele : lc.getAllAlleles())
if (alignerParameters.containsRequiredFeature(allele) &&
(allele.isFunctional() || !actionParameters.isFunctionalOnly()))
aligner.addAllele(allele);
else if (params().printWarnings() && allele.isFunctional())
System.err.println("WARNING: Functional allele excluded " + allele.getName());
for (Allele allele : lc.getAllAlleles()) {
if (actionParameters.isFunctionalOnly() && !allele.isFunctional())
continue;
if (!alignerParameters.containsRequiredFeature(allele)) {
if (params().printWarnings()) {
System.err.println("WARNING: Allele " + allele.getName() +
" doesn't contain full " + GeneFeature.encode(alignerParameters
.getFeatureToAlign(allele.getGeneType())) + " (excluded)");
warnings = true;
}
continue;
}
aligner.addAllele(allele);
}
}

if (warnings)
System.err.println("To turn off warnings use '-nw' option.");

if(aligner.getVAllelesToAlign().isEmpty()){
System.err.println("No V alleles to align. Aborting execution. See warnings for more info " +
"(turn warnings by adding -w option).");
return;
}

if(aligner.getVAllelesToAlign().isEmpty()){
System.err.println("No J alleles to align. Aborting execution. See warnings for more info " +
"(turn warnings by adding -w option).");
return;
}

AlignerReport report = actionParameters.report == null ? null : new AlignerReport();
Expand Down Expand Up @@ -194,6 +234,10 @@ public static class AlignParameters extends ActionParametersWithOutput {
names = {"-w", "--warnings"})
public Boolean warnings = null;

@Parameter(description = "Don't print warnings",
names = {"-nw", "--no-warnings"})
public Boolean noWarnings = null;

@Parameter(description = "Parameters",
names = {"-p", "--parameters"})
public String alignerParametersName = "default";
Expand Down Expand Up @@ -270,7 +314,12 @@ public String getInputForReport() {
}

public boolean printWarnings() {
return warnings != null && warnings;
if (warnings != null && noWarnings != null)
throw new ParameterException("Simultaneous use of -w and -nw.");
if (warnings == null)
return !"mi".equals(ll) && noWarnings == null;
else
return warnings;
}

public Set<Locus> getLoci() {
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/com/milaboratory/mixcr/cli/ActionAssemble.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
import com.milaboratory.mixcr.basictypes.CloneSetIO;
import com.milaboratory.mixcr.basictypes.VDJCAlignmentsReader;
import com.milaboratory.mixcr.reference.Allele;
import com.milaboratory.mixcr.reference.GeneFeature;
import com.milaboratory.mixcr.reference.GeneType;
import com.milaboratory.mixcr.reference.LociLibraryManager;
import com.milaboratory.mixcr.vdjaligners.VDJCAlignerParameters;
import com.milaboratory.primitivio.PipeWriter;
import com.milaboratory.util.SmartProgressReporter;
import org.mapdb.DB;
Expand All @@ -65,9 +68,12 @@ public class ActionAssemble implements Action {

@Override
public void go(ActionHelper helper) throws Exception {
List<Allele> alleles;
final List<Allele> alleles;
final VDJCAlignerParameters alignerParameters;
try (VDJCAlignmentsReader reader = new VDJCAlignmentsReader(actionParameters.getInputFileName(), LociLibraryManager.getDefault())) {
alleles = reader.getUsedAlleles();
// Saving aligner parameters to correct assembler parameters
alignerParameters = reader.getParameters();
}

AlignmentsProvider alignmentsProvider = AlignmentsProvider.Util.createProvider(
Expand All @@ -83,6 +89,16 @@ public void go(ActionHelper helper) throws Exception {
System.err.println("Failed to override some parameter.");
}

// Adjusting features to align for correct processing
for (GeneType geneType : GeneType.values()) {
GeneFeature featureAssemble = assemblerParameters.getCloneFactoryParameters().getFeatureToAlign(geneType);
GeneFeature featureAlignment = alignerParameters.getFeatureToAlign(geneType);
if (featureAssemble == null || featureAlignment == null)
continue;
GeneFeature intersection = GeneFeature.intersection(featureAlignment, featureAssemble);
assemblerParameters.getCloneFactoryParameters().setFeatureToAlign(geneType, intersection);
}

try (CloneAssembler assembler = new CloneAssembler(assemblerParameters, false, alleles)) {

CloneAssemblerReport report = actionParameters.report == null ? null : new CloneAssemblerReport();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,9 @@ public static String encode(GeneFeature feature) {
return encode(feature, true);
}

static String encode(GeneFeature feature, boolean copact) {
static String encode(GeneFeature feature, boolean compact) {
ensureInitialized();
if (copact) {
if (compact) {
String s = nameByFeature.get(feature);
if (s != null)
return s;
Expand All @@ -670,7 +670,7 @@ static String encode(GeneFeature feature, boolean copact) {
out:
for (int i = 0; i < encodes.length; ++i) {
ReferenceRange region = feature.regions[i];
if (copact) {
if (compact) {
String base = null;
for (GeneFeature a : available)
if (match(region, a)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@ public Allele getAllele(GeneType type, int index) {
return allelesToAlign.get(type).get(index);
}

protected List<Allele> getVAllelesToAlign() {
public List<Allele> getVAllelesToAlign() {
return allelesToAlign.get(GeneType.Variable);
}

protected List<Allele> getDAllelesToAlign() {
public List<Allele> getDAllelesToAlign() {
return allelesToAlign.get(GeneType.Diversity);
}

protected List<Allele> getJAllelesToAlign() {
public List<Allele> getJAllelesToAlign() {
return allelesToAlign.get(GeneType.Joining);
}

protected List<Allele> getCAllelesToAlign() {
public List<Allele> getCAllelesToAlign() {
return allelesToAlign.get(GeneType.Constant);
}

Expand Down
Loading

0 comments on commit 806761f

Please sign in to comment.