Skip to content

Commit

Permalink
Fixed simultaneous insertion and deletion calling.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Piechotta committed Apr 12, 2021
1 parent 151bf70 commit 968bdca
Show file tree
Hide file tree
Showing 8 changed files with 83 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.0-RC21";
public static final String TAG = "2.0.0-RC22";

// change this manually
public static final String[] LIBS = new String[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import lib.data.storage.container.SharedStorage;
import lib.data.storage.integer.ArrayIntegerStorage;
import lib.data.storage.integer.MapIntegerStorage;
import lib.data.storage.processor.CoverageRecordProcessor;
import lib.data.storage.processor.DeletionRecordProcessor;
import lib.data.storage.processor.InsertionRecordProcessor;
import lib.data.storage.readsubstitution.BaseCallInterpreter;
Expand Down Expand Up @@ -69,7 +70,6 @@ protected void addDeletionCache(
if (parameter.showDeletionCount()) {
cache.addCache(createDeletionCache(
sharedStorage,
DataType.COVERAGE.getFetcher(),
DataType.DELETION_COUNT.getFetcher()));
}
}
Expand All @@ -82,49 +82,50 @@ protected void addInsertionCache(
if (parameter.showInsertionCount()) {
cache.addCache(createInsertionCache(
sharedStorage,
DataType.COVERAGE.getFetcher(),
DataType.INSERTION_COUNT.getFetcher()));
}
}

Cache createDeletionCache(
final SharedStorage sharedStorage,
final Fetcher<IntegerData> covFetcher, final Fetcher<IntegerData> delFetcher) {

Cache createCoverageCache(final SharedStorage sharedStorage, final Fetcher<IntegerData> covFetcher) {
final Cache cache = new Cache();
final Storage covStorage = new ArrayIntegerStorage(sharedStorage, covFetcher);
cache.addStorage(covStorage);


final CoordinateTranslator translator = sharedStorage.getCoordinateController()
.getCoordinateTranslator();

cache.addRecordProcessor(new CoverageRecordProcessor(translator, covStorage));
return cache;
}

Cache createDeletionCache(
final SharedStorage sharedStorage, final Fetcher<IntegerData> delFetcher) {

final Cache cache = new Cache();

final Storage delStorage = new MapIntegerStorage(sharedStorage, delFetcher);
cache.addStorage(delStorage);

final CoordinateTranslator translator = sharedStorage.getCoordinateController()
.getCoordinateTranslator();

cache.addRecordProcessor(new DeletionRecordProcessor(
translator,
covStorage, delStorage));

cache.addRecordProcessor(new DeletionRecordProcessor(translator, delStorage));

return cache;
}

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

final Cache cache = new Cache();
final Storage covStorage = new ArrayIntegerStorage(sharedStorage, covFetcher);
cache.addStorage(covStorage);

final Storage insStorage = new MapIntegerStorage(sharedStorage, insFetcher);
cache.addStorage(insStorage);

final CoordinateTranslator translator = sharedStorage.getCoordinateController()
.getCoordinateTranslator();

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

return cache;
}
Expand Down
8 changes: 6 additions & 2 deletions src/lib/data/assembler/factory/CallDataAssemblerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@ protected Cache createCache(

final PositionProcessor positionProcessor = new PositionProcessor(validators, bcqcStorage);
cache.addRecordProcessor(new AlignmentBlockProcessor(translator, positionProcessor));


if (parameter.showInsertionCount() || parameter.showDeletionCount()) {
cache.addCache(createCoverageCache(sharedStorage, DataType.COVERAGE.getFetcher()));
}
addDeletionCache(parameter, sharedStorage, cache);
addInsertionCache(parameter, sharedStorage, cache);

stratifyByBaseSub(parameter, sharedStorage, conditionParameter, cache);

return cache;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ protected Cache createCache(
positionProcessor));
cache.addStorage(bcqcStorage);

if (parameter.showInsertionCount() || parameter.showDeletionCount()) {
cache.addCache(createCoverageCache(sharedStorage, DataType.COVERAGE.getFetcher()));
}
addInsertionCache(parameter, sharedStorage, cache);
addDeletionCache(parameter, sharedStorage, cache);
stratifyByBaseSub(parameter, sharedStorage, conditionParameter, cache);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public Cache createCache(
locInterpreter,
validators));

if (parameter.showInsertionCount() || parameter.showDeletionCount()) {
cache.addCache(createCoverageCache(sharedStorage, DataType.COVERAGE.getFetcher()));
}
addInsertionCache(parameter, sharedStorage, cache);
addDeletionCache(parameter, sharedStorage, cache);

// stratify by base substitutions
Expand Down
48 changes: 48 additions & 0 deletions src/lib/data/storage/processor/CoverageRecordProcessor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package lib.data.storage.processor;

import lib.data.storage.Storage;
import lib.record.Record;
import lib.util.coordinate.CoordinateTranslator;
import lib.util.position.ConsumingRefPosProviderBuilder;
import lib.util.position.Position;
import lib.util.position.PositionProvider;

/**
* TODO
*/
public class CoverageRecordProcessor implements GeneralRecordProcessor {

private final CoordinateTranslator translator;

private final Storage covStorage;

public CoverageRecordProcessor(
final CoordinateTranslator translator,
final Storage covStorage) {

this.translator = translator;
this.covStorage = covStorage;
}

@Override
public void preProcess() {
// nothing to be done
}

@Override
public void process(final Record record) {
// store total coverage
final PositionProvider covPosProvider =
new ConsumingRefPosProviderBuilder(record, translator).build();
while (covPosProvider.hasNext()) {
final Position pos = covPosProvider.next();
covStorage.increment(pos);
}
}

@Override
public void postProcess() {
// nothing to be done
}

}
12 changes: 0 additions & 12 deletions src/lib/data/storage/processor/DeletionRecordProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import lib.record.Record;
import lib.util.coordinate.CoordinateTranslator;
import lib.util.position.AllDeletionsPositionProvider;
import lib.util.position.ConsumingRefPosProviderBuilder;
import lib.util.position.Position;
import lib.util.position.PositionProvider;

Expand All @@ -15,16 +14,13 @@ public class DeletionRecordProcessor implements GeneralRecordProcessor {

private final CoordinateTranslator translator;

private final Storage covStorage;
private final Storage delStorage;

public DeletionRecordProcessor(
final CoordinateTranslator translator,
final Storage covStorage,
final Storage delStorage) {

this.translator = translator;
this.covStorage = covStorage;
this.delStorage = delStorage;
}

Expand All @@ -35,14 +31,6 @@ public void preProcess() {

@Override
public void process(final Record record) {
// store total coverage
final PositionProvider covPosProvider =
new ConsumingRefPosProviderBuilder(record, translator).build();
while (covPosProvider.hasNext()) {
final Position pos = covPosProvider.next();
covStorage.increment(pos);
}

// store deletions
final PositionProvider delPosProvider =
new AllDeletionsPositionProvider(record, translator);
Expand Down
14 changes: 1 addition & 13 deletions src/lib/data/storage/processor/InsertionRecordProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import lib.record.Record;
import lib.util.coordinate.CoordinateTranslator;
import lib.util.position.AllInsertionsPosProvider;
import lib.util.position.ConsumingRefPosProviderBuilder;
import lib.util.position.Position;
import lib.util.position.PositionProvider;

Expand All @@ -15,16 +14,13 @@ public class InsertionRecordProcessor implements GeneralRecordProcessor {

private final CoordinateTranslator translator;

private final Storage covStorage;
private final Storage insStorage;

public InsertionRecordProcessor(
final CoordinateTranslator translator,
final Storage covStorage,
final Storage insStorage) {

this.translator = translator;
this.covStorage = covStorage;
this.insStorage = insStorage;
}

Expand All @@ -35,15 +31,7 @@ public void preProcess() {

@Override
public void process(final Record record) {
// store total coverage
final PositionProvider covPosProvider =
new ConsumingRefPosProviderBuilder(record, translator).build();
while (covPosProvider.hasNext()) {
final Position pos = covPosProvider.next();
covStorage.increment(pos);
}

// store insetions
// store insertions
final PositionProvider insPosProvider =
new AllInsertionsPosProvider(record, translator);
while (insPosProvider.hasNext()) {
Expand Down

0 comments on commit 968bdca

Please sign in to comment.