diff --git a/src/jacusa/VersionInfo.java b/src/jacusa/VersionInfo.java index f071dd63..df1f0aa8 100644 --- a/src/jacusa/VersionInfo.java +++ b/src/jacusa/VersionInfo.java @@ -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[] { diff --git a/src/lib/data/assembler/factory/AbstractSiteDataAssemblerFactory.java b/src/lib/data/assembler/factory/AbstractSiteDataAssemblerFactory.java index 67e6f9be..ce7e48f1 100644 --- a/src/lib/data/assembler/factory/AbstractSiteDataAssemblerFactory.java +++ b/src/lib/data/assembler/factory/AbstractSiteDataAssemblerFactory.java @@ -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; @@ -69,7 +70,6 @@ protected void addDeletionCache( if (parameter.showDeletionCount()) { cache.addCache(createDeletionCache( sharedStorage, - DataType.COVERAGE.getFetcher(), DataType.DELETION_COUNT.getFetcher())); } } @@ -82,39 +82,42 @@ protected void addInsertionCache( if (parameter.showInsertionCount()) { cache.addCache(createInsertionCache( sharedStorage, - DataType.COVERAGE.getFetcher(), DataType.INSERTION_COUNT.getFetcher())); } } - Cache createDeletionCache( - final SharedStorage sharedStorage, - final Fetcher covFetcher, final Fetcher delFetcher) { - + Cache createCoverageCache(final SharedStorage sharedStorage, final Fetcher 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 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 covFetcher, final Fetcher insFetcher) { + final SharedStorage sharedStorage, final Fetcher 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); @@ -122,9 +125,7 @@ Cache createInsertionCache( final CoordinateTranslator translator = sharedStorage.getCoordinateController() .getCoordinateTranslator(); - cache.addRecordProcessor(new InsertionRecordProcessor( - translator, - covStorage, insStorage)); + cache.addRecordProcessor(new InsertionRecordProcessor(translator, insStorage)); return cache; } diff --git a/src/lib/data/assembler/factory/CallDataAssemblerFactory.java b/src/lib/data/assembler/factory/CallDataAssemblerFactory.java index 2302bead..4714b45d 100644 --- a/src/lib/data/assembler/factory/CallDataAssemblerFactory.java +++ b/src/lib/data/assembler/factory/CallDataAssemblerFactory.java @@ -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; } diff --git a/src/lib/data/assembler/factory/PileupDataAssemblerFactory.java b/src/lib/data/assembler/factory/PileupDataAssemblerFactory.java index fadf166c..b1eebf69 100644 --- a/src/lib/data/assembler/factory/PileupDataAssemblerFactory.java +++ b/src/lib/data/assembler/factory/PileupDataAssemblerFactory.java @@ -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); diff --git a/src/lib/data/assembler/factory/RTarrestDataAssemblerFactory.java b/src/lib/data/assembler/factory/RTarrestDataAssemblerFactory.java index 60852b0e..d3c2d873 100644 --- a/src/lib/data/assembler/factory/RTarrestDataAssemblerFactory.java +++ b/src/lib/data/assembler/factory/RTarrestDataAssemblerFactory.java @@ -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 diff --git a/src/lib/data/storage/processor/CoverageRecordProcessor.java b/src/lib/data/storage/processor/CoverageRecordProcessor.java new file mode 100644 index 00000000..b5e016cd --- /dev/null +++ b/src/lib/data/storage/processor/CoverageRecordProcessor.java @@ -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 + } + +} diff --git a/src/lib/data/storage/processor/DeletionRecordProcessor.java b/src/lib/data/storage/processor/DeletionRecordProcessor.java index 5f8ea78b..16b7095a 100644 --- a/src/lib/data/storage/processor/DeletionRecordProcessor.java +++ b/src/lib/data/storage/processor/DeletionRecordProcessor.java @@ -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; @@ -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; } @@ -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); diff --git a/src/lib/data/storage/processor/InsertionRecordProcessor.java b/src/lib/data/storage/processor/InsertionRecordProcessor.java index 6924f5e1..e69c59ce 100644 --- a/src/lib/data/storage/processor/InsertionRecordProcessor.java +++ b/src/lib/data/storage/processor/InsertionRecordProcessor.java @@ -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; @@ -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; } @@ -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()) {