/** * Update the recalibration statistics using the information in recalInfo * * @param recalInfo data structure holding information about the recalibration values for a single * read */ @Requires("recalInfo != null") public void updateDataForRead(final ReadRecalibrationInfo recalInfo) { final GATKSAMRecord read = recalInfo.getRead(); final ReadCovariates readCovariates = recalInfo.getCovariatesValues(); final RecalibrationTables tables = getUpdatableRecalibrationTables(); final NestedIntegerArray<RecalDatum> qualityScoreTable = tables.getQualityScoreTable(); for (int offset = 0; offset < read.getReadBases().length; offset++) { if (!recalInfo.skip(offset)) { for (final EventType eventType : EventType.values()) { final int[] keys = readCovariates.getKeySet(offset, eventType); final int eventIndex = eventType.ordinal(); final byte qual = recalInfo.getQual(eventType, offset); final double isError = recalInfo.getErrorFraction(eventType, offset); RecalUtils.incrementDatumOrPutIfNecessary( qualityScoreTable, qual, isError, keys[0], keys[1], eventIndex); for (int i = 2; i < covariates.length; i++) { if (keys[i] < 0) continue; RecalUtils.incrementDatumOrPutIfNecessary( tables.getTable(i), qual, isError, keys[0], keys[1], keys[i], eventIndex); } } } } }
public static EventType parse(String value) { EventType[] v = EventType.values(); for (EventType val : v) { if (val.toString().equals(value)) { return val; } } return null; }
public EventTargets() { final int EVENTS_COUNT = EventType.values().length; mEvents = new ArrayList<>(EVENTS_COUNT); for (int i = 0; i < EVENTS_COUNT; i++) { mEvents.add(new ArrayList<CallType>(1)); } // initTargetCalls(); // for (int i = 0; i < EVENTS_COUNT; i++) { mEvents.set(i, Collections.unmodifiableList(mEvents.get(i))); } }
public void activateMetrics() { // Activate Plugin Metrics try { Metrics metrics = new Metrics(this); metrics.addCustomData( new Metrics.Plotter("Total Number of Server Rules") { @Override public int getValue() { return ruleset.ruleCount(); } }); Metrics.Graph graph = metrics.createGraph("Rules by Event"); for (final EventType r : EventType.values()) { graph.addPlotter( new Metrics.Plotter(r.toString()) { @Override public int getValue() { return ruleset.ruleCount(r); // Number of rules for this event type } }); } Metrics.Graph matchGraph = metrics.createGraph("Matches"); matchTracker = new Tracker("Matches"); matchGraph.addPlotter(matchTracker); metrics.start(); } catch (IOException e) { logger.fine(e.getMessage()); } }
/** Utility class to facilitate base quality score recalibration. */ public final class RecalibrationTables implements Serializable, Iterable<NestedIntegerArray<RecalDatum>> { private static final long serialVersionUID = 1L; private final int qualDimension; private final int eventDimension = EventType.values().length; private final int numReadGroups; final StandardCovariateList covariates; // save the covariates this was created with // These two tables are special private final NestedIntegerArray<RecalDatum> readGroupTable; private final NestedIntegerArray<RecalDatum> qualityScoreTable; private final List<NestedIntegerArray<RecalDatum>> additionalTables; private final List<NestedIntegerArray<RecalDatum>> allTables; // special + additional // bidirectional mappings private final Map<Covariate, NestedIntegerArray<RecalDatum>> covariateToTable; private final Map<NestedIntegerArray<RecalDatum>, Covariate> tableToCovariate; public RecalibrationTables(final StandardCovariateList covariates) { this(covariates, covariates.getReadGroupCovariate().maximumKeyValue() + 1); } public RecalibrationTables(StandardCovariateList covariates, final int numReadGroups) { this.covariates = covariates; this.additionalTables = new ArrayList<>(); this.allTables = new ArrayList<>(); this.covariateToTable = new LinkedHashMap<>(); this.tableToCovariate = new LinkedHashMap<>(); this.qualDimension = covariates.getQualityScoreCovariate().maximumKeyValue() + 1; this.numReadGroups = numReadGroups; // two special tables this.readGroupTable = new NestedIntegerArray<>(numReadGroups, eventDimension); allTables.add(readGroupTable); covariateToTable.put(covariates.getReadGroupCovariate(), readGroupTable); tableToCovariate.put(readGroupTable, covariates.getReadGroupCovariate()); this.qualityScoreTable = makeQualityScoreTable(); allTables.add(qualityScoreTable); covariateToTable.put(covariates.getQualityScoreCovariate(), qualityScoreTable); tableToCovariate.put(qualityScoreTable, covariates.getQualityScoreCovariate()); // Non-special tables for (Covariate cov : covariates.getAdditionalCovariates()) { final NestedIntegerArray<RecalDatum> table = new NestedIntegerArray<>( numReadGroups, qualDimension, cov.maximumKeyValue() + 1, eventDimension); additionalTables.add(table); allTables.add(table); covariateToTable.put(cov, table); tableToCovariate.put(table, cov); } } public NestedIntegerArray<RecalDatum> getTableForCovariate(Covariate cov) { return covariateToTable.get(cov); } public Covariate getCovariateForTable(NestedIntegerArray<RecalDatum> table) { return tableToCovariate.get(table); } public boolean isReadGroupTable(NestedIntegerArray<RecalDatum> table) { // Note: NestedIntegerArray does not implement equals so we use reference identity to check // equality // to explicitly check identity (and future-proof against an equals method in // NestedIntegerArray). return table == getReadGroupTable(); } public boolean isQualityScoreTable(NestedIntegerArray<RecalDatum> table) { // Note: NestedIntegerArray does not implement equals so we use reference identity to check // equality // to explicitly check identity (and future-proof against an equals method in // NestedIntegerArray). return table == getQualityScoreTable(); } public boolean isAdditionalCovariateTable(NestedIntegerArray<RecalDatum> table) { return additionalTables.contains(table); } public NestedIntegerArray<RecalDatum> getReadGroupTable() { return readGroupTable; } public NestedIntegerArray<RecalDatum> getQualityScoreTable() { return qualityScoreTable; } public int numTables() { return allTables.size(); } @Override public Iterator<NestedIntegerArray<RecalDatum>> iterator() { return allTables.iterator(); } /** @return true if all the tables contain no RecalDatums */ public boolean isEmpty() { for (final NestedIntegerArray<RecalDatum> table : allTables) { if (!table.getAllValues().isEmpty()) { return false; } } return true; } /** * Allocate a new quality score table, based on requested parameters in this set of tables, * without any data in it. The return result of this table is suitable for acting as a * thread-local cache for quality score values * * @return a newly allocated, empty read group x quality score table */ public NestedIntegerArray<RecalDatum> makeQualityScoreTable() { return new NestedIntegerArray<>(numReadGroups, qualDimension, eventDimension); } /** Merge all of the tables from toMerge into into this set of tables */ public RecalibrationTables combine(final RecalibrationTables toMerge) { if (numTables() != toMerge.numTables()) throw new IllegalArgumentException( "Attempting to merge RecalibrationTables with different sizes"); for (int i = 0; i < numTables(); i++) { final NestedIntegerArray<RecalDatum> myTable = this.allTables.get(i); final NestedIntegerArray<RecalDatum> otherTable = toMerge.allTables.get(i); RecalUtils.combineTables(myTable, otherTable); } return this; } /** * Combines the two tables into a new table (allocating a new table in the process) * * @param left first table to combine * @param right second table to combine * @return a new table with the merged contents of left and right */ public static RecalibrationTables safeCombine( final RecalibrationTables left, final RecalibrationTables right) { Utils.nonNull(left); Utils.nonNull(right); final RecalibrationTables newTable = new RecalibrationTables(left.covariates, left.numReadGroups); newTable.combine(left); newTable.combine(right); return newTable; } /** * Combines the right table into the left table, in-place (without making a copy) * * @param left first table to combine * @param right second table to combine * @return modified version of left with the contents of right incorporated into it */ public static RecalibrationTables inPlaceCombine( final RecalibrationTables left, final RecalibrationTables right) { Utils.nonNull(left); Utils.nonNull(right); return left.combine(right); } // XXX this should not be accessible by index public NestedIntegerArray<RecalDatum> getTable(int index) { return allTables.get(index); } public List<NestedIntegerArray<RecalDatum>> getAdditionalTables() { return additionalTables; } }
public void configurePlugin() { if (getConfig().getBoolean("logfile")) { setupLogfile(); } else { // Needed during configuration reload to turn off logging if the option changes if (logfileHandler != null) { logfileHandler.close(); logger.removeHandler(logfileHandler); logfileHandler = null; } } try { ruleLogLevel = Level.parse(getConfig().getString("loglevel", "info").toUpperCase()); } catch (IllegalArgumentException e) { ruleLogLevel = Level.INFO; } decolor = getConfig().getBoolean("decolor"); try { debugMode = DebugModes.valueOf(getConfig().getString("debug")); } catch (IllegalArgumentException e) { debugMode = DebugModes.off; } cmdlist = getConfig().getStringList("cmdlist"); cmdblist = getConfig().getStringList("cmdblist"); enabledEvents.clear(); // Reset the enabled event types. for (EventType e : EventType.values()) { switch (e) { case CHAT: chatPriority = EventPriority.valueOf(getConfig().getString("chatpriority", "LOWEST").toUpperCase()); enabledEvents.add(EventType.CHAT); break; case COMMAND: if (getConfig().getBoolean("commandfilter", false)) { cmdPriority = EventPriority.valueOf(getConfig().getString("cmdpriority", "LOWEST").toUpperCase()); enabledEvents.add(EventType.COMMAND); } break; case SIGN: if (getConfig().getBoolean("signfilter", false)) { signPriority = EventPriority.valueOf( getConfig().getString("signpriority", "LOWEST").toUpperCase()); enabledEvents.add(EventType.SIGN); } break; case ITEM: if (getConfig().getBoolean("itemfilter", false)) { invPriority = EventPriority.valueOf(getConfig().getString("invpriority", "LOWEST").toUpperCase()); enabledEvents.add(EventType.ITEM); } break; } } }