Skip to content

Commit

Permalink
* Fixed cache problem, when calculating test-statistic for INDELs.
Browse files Browse the repository at this point in the history
* Added new Option "-i" Count only the start position of an insertion
  • Loading branch information
piechottam committed Jun 1, 2023
1 parent b1b1032 commit 0a2be5e
Show file tree
Hide file tree
Showing 20 changed files with 130 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/jacusa/VersionInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public final class VersionInfo {

public static final String BRANCH = "master";
public static final String TAG = "2.0.2-RC";
public static final String TAG = "2.0.4";

// change this manually
public static final String[] LIBS = new String[] {
Expand Down
6 changes: 4 additions & 2 deletions src/jacusa/method/call/CallMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import lib.cli.options.ShowAllSitesOption;
import lib.cli.options.ShowDeletionCountOption;
import lib.cli.options.ShowInsertionCountOption;
import lib.cli.options.ShowInsertionStartCountOption;
import lib.cli.options.HelpOption;
import lib.cli.options.MaxThreadOption;
import lib.cli.options.ResultFileOption;
Expand Down Expand Up @@ -121,6 +122,7 @@ protected void initGlobalACOptions() {
addACOption(new StratifyByReadTagOption(getParameter()));
addACOption(new ShowDeletionCountOption(getParameter()));
addACOption(new ShowInsertionCountOption(getParameter()));
addACOption(new ShowInsertionStartCountOption(getParameter()));

addACOption(new BedCoordinatesOption(getParameter()));
addACOption(new ResultFileOption(getParameter()));
Expand Down Expand Up @@ -276,7 +278,7 @@ protected void addRequired(final AbstractBuilder builder) {
addBaseSub2int(builder, DataType.BASE_SUBST2DELETION_COUNT);
addBaseSub2int(builder, DataType.BASE_SUBST2COVERAGE);
}
if (parameter.showInsertionCount()) {
if (parameter.showInsertionCount() || parameter.showInsertionStartCount()) {
addBaseSub2int(builder, DataType.BASE_SUBST2INSERTION_COUNT);
addBaseSub2int(builder, DataType.BASE_SUBST2COVERAGE);
}
Expand All @@ -285,7 +287,7 @@ protected void addRequired(final AbstractBuilder builder) {
add(builder, DataType.DELETION_COUNT);
guardedAdd(builder, DataType.COVERAGE);
}
if (parameter.showInsertionCount()) {
if (parameter.showInsertionCount() || parameter.showInsertionStartCount()) {
add(builder, DataType.INSERTION_COUNT);
guardedAdd(builder, DataType.COVERAGE);
}
Expand Down
6 changes: 4 additions & 2 deletions src/jacusa/method/pileup/PileupMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import lib.cli.options.ResultFormatOption;
import lib.cli.options.ShowDeletionCountOption;
import lib.cli.options.ShowInsertionCountOption;
import lib.cli.options.ShowInsertionStartCountOption;
import lib.cli.options.ThreadWindowSizeOption;
import lib.cli.options.WindowSizeOption;
import lib.cli.options.condition.MaxDepthConditionOption;
Expand Down Expand Up @@ -99,6 +100,7 @@ protected void initGlobalACOptions() {
addACOption(new StratifyByReadTagOption(getParameter()));
addACOption(new ShowDeletionCountOption(getParameter()));
addACOption(new ShowInsertionCountOption(getParameter()));
addACOption(new ShowInsertionStartCountOption(getParameter()));

addACOption(new BedCoordinatesOption(getParameter()));
addACOption(new ResultFileOption(getParameter()));
Expand Down Expand Up @@ -239,7 +241,7 @@ protected void addRequired(final AbstractBuilder builder) {
addBaseSub2int(builder, DataType.BASE_SUBST2DELETION_COUNT);
addBaseSub2int(builder, DataType.BASE_SUBST2COVERAGE);
}
if (parameter.showInsertionCount()) {
if (parameter.showInsertionCount() || parameter.showInsertionStartCount()) {
addBaseSub2int(builder, DataType.BASE_SUBST2INSERTION_COUNT);
addBaseSub2int(builder, DataType.BASE_SUBST2COVERAGE);
}
Expand All @@ -248,7 +250,7 @@ protected void addRequired(final AbstractBuilder builder) {
add(builder, DataType.DELETION_COUNT);
guardedAdd(builder, DataType.COVERAGE);
}
if (parameter.showInsertionCount()) {
if (parameter.showInsertionCount() || parameter.showInsertionStartCount()) {
add(builder, DataType.INSERTION_COUNT);
guardedAdd(builder, DataType.COVERAGE);
}
Expand Down
6 changes: 4 additions & 2 deletions src/jacusa/method/rtarrest/RTarrestMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import lib.cli.options.ResultFormatOption;
import lib.cli.options.ShowDeletionCountOption;
import lib.cli.options.ShowInsertionCountOption;
import lib.cli.options.ShowInsertionStartCountOption;
import lib.cli.options.HelpOption;
import lib.cli.options.MaxThreadOption;
import lib.cli.options.ResultFileOption;
Expand Down Expand Up @@ -114,6 +115,7 @@ protected void initGlobalACOptions() {
addACOption(new StratifyByReadTagOption(getParameter()));
addACOption(new ShowDeletionCountOption(getParameter()));
addACOption(new ShowInsertionCountOption(getParameter()));
addACOption(new ShowInsertionStartCountOption(getParameter()));

addACOption(new BedCoordinatesOption(getParameter()));
addACOption(new ResultFileOption(getParameter()));
Expand Down Expand Up @@ -293,7 +295,7 @@ protected void addRequired(final AbstractBuilder builder) {
addBaseSub2int(builder, DataType.BASE_SUBST2DELETION_COUNT);
addBaseSub2int(builder, DataType.BASE_SUBST2COVERAGE);
}
if (parameter.showInsertionCount()) {
if (parameter.showInsertionCount() || parameter.showInsertionStartCount()) {
addBaseSub2int(builder, DataType.BASE_SUBST2INSERTION_COUNT);
addBaseSub2int(builder, DataType.BASE_SUBST2COVERAGE);
}
Expand All @@ -302,7 +304,7 @@ protected void addRequired(final AbstractBuilder builder) {
add(builder, DataType.DELETION_COUNT);
guardedAdd(builder, DataType.COVERAGE);
}
if (parameter.showInsertionCount()) {
if (parameter.showInsertionCount() || parameter.showInsertionStartCount()) {
add(builder, DataType.INSERTION_COUNT);
guardedAdd(builder, DataType.COVERAGE);
}
Expand Down
2 changes: 1 addition & 1 deletion src/jacusa/worker/CallWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected Result process(final ParallelData parallelData) {
result = new DeletionCountResult(baseSubs, result, minkaPrm, delCountProv);
}

if (getParameter().showInsertionCount()) {
if (getParameter().showInsertionCount() || getParameter().showInsertionStartCount()) {
final MinkaParameter minkaPrm = new MinkaParameter();
final InsertionEstCountProvider insCountProv =
new InsertionEstCountProvider(minkaPrm.getMaxIterations());
Expand Down
2 changes: 1 addition & 1 deletion src/jacusa/worker/PileupWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected Result process(final ParallelData parallelData) {
result = new DeletionCountResult(baseSubs, result, minkaPrm, delCountProv);
}

if (getParameter().showInsertionCount()) {
if (getParameter().showInsertionCount() || getParameter().showInsertionStartCount()) {
final MinkaParameter minkaPrm = new MinkaParameter();
final InsertionEstCountProvider insCountProv =
new InsertionEstCountProvider(minkaPrm.getMaxIterations());
Expand Down
2 changes: 1 addition & 1 deletion src/jacusa/worker/RTArrestWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected Result process(final ParallelData parallelData) {
result = new DeletionCountResult(baseSubs, result, minkaPrm, delCountProv);
}

if (getParameter().showInsertionCount()) {
if (getParameter().showInsertionCount() || getParameter().showInsertionStartCount()) {
final MinkaParameter minkaPrm = new MinkaParameter();
final InsertionEstCountProvider insCountProv =
new InsertionEstCountProvider(minkaPrm.getMaxIterations());
Expand Down
34 changes: 34 additions & 0 deletions src/lib/cli/options/ShowInsertionStartCountOption.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package lib.cli.options;

import lib.cli.parameter.GeneralParameter;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;

public class ShowInsertionStartCountOption extends AbstractACOption {

private final GeneralParameter parameter;

public ShowInsertionStartCountOption(final GeneralParameter parameter) {
super("i", "show-start-insertions");
this.parameter = parameter;
}

@Override
public Option getOption(final boolean printExtendedHelp) {
return Option.builder(getOpt())
.hasArg(false)
.desc("Show start insertion score")
.build();
}

/**
* Tested in @see test.lib.cli.options.FilterModusOptionTest
*/

@Override
public void process(final CommandLine line) throws Exception {
parameter.showInsertionStartsCount(true);
}

}
21 changes: 18 additions & 3 deletions src/lib/cli/parameter/GeneralParameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class GeneralParameter
private final SortedSet<BaseSub> baseSubs;
private boolean showDeletionCount;
private boolean showInsertionCount;
private boolean showInsertionStartCount;
private boolean showAllSites;

// debug flag
Expand Down Expand Up @@ -227,21 +228,35 @@ public boolean showDeletionCount() {
public boolean showInsertionCount() {
return showInsertionCount;
}

public boolean showInsertionStartCount() {
return showInsertionStartCount;
}

/**
* @param showDeletionCount the showDeletionCount to set
*/
public void showDeletionCount(boolean showDeletionCount) {
this.showDeletionCount = showDeletionCount;
}

/**
* @param showInsertionCount the showInsertionCount to set
*/
public void showInsertionCount(boolean showInsertionCount) {
public void showInsertionCount(boolean showInsertionCount) throws Exception {
if (showInsertionStartCount && showInsertionCount) {
throw new Exception("Cannot set both to true");
}
this.showInsertionCount = showInsertionCount;
}


public void showInsertionStartsCount(boolean showInsertionStartCount) throws Exception {
if (this.showInsertionCount && showInsertionStartCount) {
throw new Exception("Cannot set both to true");
}
this.showInsertionStartCount = showInsertionStartCount;
}

/**
* @return the showDeletionCount
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ protected void addInsertionCache(
final SharedStorage sharedStorage,
final Cache cache) {

if (parameter.showInsertionCount()) {
cache.addCache(createInsertionCache(
sharedStorage,
DataType.INSERTION_COUNT.getFetcher()));
if (parameter.showInsertionCount() || parameter.showInsertionStartCount()) {
final boolean onlyStart = parameter.showInsertionStartCount();
cache.addCache(createInsertionCache(
sharedStorage,
DataType.INSERTION_COUNT.getFetcher(),
onlyStart));
}
}

Expand Down Expand Up @@ -115,7 +117,7 @@ Cache createDeletionCache(
}

Cache createInsertionCache(
final SharedStorage sharedStorage, final Fetcher<IntegerData> insFetcher) {
final SharedStorage sharedStorage, final Fetcher<IntegerData> insFetcher, final boolean onlyStart) {

final Cache cache = new Cache();

Expand All @@ -125,7 +127,7 @@ Cache createInsertionCache(
final CoordinateTranslator translator = sharedStorage.getCoordinateController()
.getCoordinateTranslator();

cache.addRecordProcessor(new InsertionRecordProcessor(translator, insStorage));
cache.addRecordProcessor(new InsertionRecordProcessor(translator, insStorage, onlyStart));

return cache;
}
Expand Down Expand Up @@ -174,7 +176,7 @@ protected void stratifyByBaseSub(
algnPosProc.addStorage(bccStorage);
baseSub2algnPosProc.put(baseSub, algnPosProc);

if (prm.showInsertionCount() || prm.showDeletionCount()) {
if (prm.showInsertionCount() || prm.showInsertionStartCount() || prm.showDeletionCount()) {
final PositionProcessor covPosProc = new PositionProcessor();
final Fetcher<IntegerData> covFetcher = new IntegerDataExtractor(
baseSub,
Expand All @@ -186,7 +188,7 @@ protected void stratifyByBaseSub(
covPosProc.addStorage(covStorage);
baseSub2covPosProc.put(baseSub, covPosProc);
}
if (prm.showInsertionCount()) {
if (prm.showInsertionCount() || prm.showInsertionStartCount()) {
final PositionProcessor insPosProc = new PositionProcessor();
final Fetcher<IntegerData> insFetcher = new IntegerDataExtractor(
baseSub,
Expand Down Expand Up @@ -221,7 +223,8 @@ protected void stratifyByBaseSub(
baseSub2algnPosProc,
baseSub2covPosProc,
baseSub2insPosProc,
baseSub2delPosProc));
baseSub2delPosProc,
prm.showInsertionStartCount()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected Cache createCache(
final PositionProcessor positionProcessor = new PositionProcessor(validators, bcqcStorage);
cache.addRecordProcessor(new AlignmentBlockProcessor(translator, positionProcessor));

if (parameter.showInsertionCount() || parameter.showDeletionCount()) {
if (parameter.showInsertionCount() || parameter.showInsertionStartCount() || parameter.showDeletionCount()) {
cache.addCache(createCoverageCache(sharedStorage, DataType.COVERAGE.getFetcher()));
}
addDeletionCache(parameter, sharedStorage, cache);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected Cache createCache(
positionProcessor));
cache.addStorage(bcqcStorage);

if (parameter.showInsertionCount() || parameter.showDeletionCount()) {
if (parameter.showInsertionCount() || parameter.showInsertionStartCount() || parameter.showDeletionCount()) {
cache.addCache(createCoverageCache(sharedStorage, DataType.COVERAGE.getFetcher()));
}
addInsertionCache(parameter, sharedStorage, cache);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Cache createCache(
locInterpreter,
validators));

if (parameter.showInsertionCount() || parameter.showDeletionCount()) {
if (parameter.showInsertionCount() || parameter.showInsertionStartCount() || parameter.showDeletionCount()) {
cache.addCache(createCoverageCache(sharedStorage, DataType.COVERAGE.getFetcher()));
}
addInsertionCache(parameter, sharedStorage, cache);
Expand Down Expand Up @@ -161,7 +161,7 @@ private Cache createStratifyByBaseSub(
alignedPosProcessor.addStorage(rtArrestCountStorage);
baseSub2alignedPosProcessor.put(baseSub, alignedPosProcessor);

if (parameter.showInsertionCount() || parameter.showDeletionCount()) {
if (parameter.showInsertionCount() || parameter.showInsertionStartCount() || parameter.showDeletionCount()) {
final PositionProcessor covPosProcessor = new PositionProcessor();
final Fetcher<IntegerData> covFetcher = new IntegerDataExtractor(
baseSub,
Expand All @@ -173,7 +173,7 @@ private Cache createStratifyByBaseSub(
covPosProcessor.addStorage(covStorage);
baseSub2covPosProcessor.put(baseSub, covPosProcessor);
}
if (parameter.showInsertionCount()) {
if (parameter.showInsertionCount() || parameter.showInsertionStartCount()) {
final PositionProcessor insPosProcessor = new PositionProcessor();
final Fetcher<IntegerData> insFetcher = new IntegerDataExtractor(
baseSub,
Expand Down Expand Up @@ -211,7 +211,8 @@ private Cache createStratifyByBaseSub(
baseSub2alignedPosProcessor,
baseSub2covPosProcessor,
baseSub2insPosProcessor,
baseSub2delPosProcessor) );
baseSub2delPosProcessor,
parameter.showInsertionStartCount()));
return cache;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void preProcess() {
// nothing to be done
}

@Override
@Override // TODO adjust deletion at every position
public void process(final Record record) {
// store deletions
final PositionProvider delPosProvider =
Expand Down
7 changes: 5 additions & 2 deletions src/lib/data/storage/processor/InsertionRecordProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ public class InsertionRecordProcessor implements GeneralRecordProcessor {
private final CoordinateTranslator translator;

private final Storage insStorage;
private final boolean onlyStart;

public InsertionRecordProcessor(
final CoordinateTranslator translator,
final Storage insStorage) {
final Storage insStorage,
final boolean onlyStart) {

this.translator = translator;
this.insStorage = insStorage;
this.onlyStart = onlyStart;
}

@Override
Expand All @@ -33,7 +36,7 @@ public void preProcess() {
public void process(final Record record) {
// store insertions
final PositionProvider insPosProvider =
new AllInsertionsPosProvider(record, translator);
new AllInsertionsPosProvider(record, translator, onlyStart);
while (insPosProvider.hasNext()) {
final Position pos = insPosProvider.next();
insStorage.increment(pos);
Expand Down
Loading

0 comments on commit 0a2be5e

Please sign in to comment.