Java Code Examples for org.apache.commons.lang3.tuple.Triple#getLeft()
The following examples show how to use
org.apache.commons.lang3.tuple.Triple#getLeft() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerProxy.java From Better-Sprinting with Mozilla Public License 2.0 | 6 votes |
@Override public void migrateConfig(List<Triple<Character, String, String>> oldConfig){ for(Triple<Character, String, String> entry:oldConfig){ if (entry.getLeft() == 'B'){ BooleanValue value; switch(entry.getMiddle()){ case "disableClientMod": value = ServerSettings.disableClientMod; break; case "enableSurvivalFlyBoost": value = ServerSettings.enableSurvivalFlyBoost; break; case "enableAllDirs": value = ServerSettings.enableAllDirs; break; default: continue; } BetterSprintingMod.config.set(value, entry.getRight().equalsIgnoreCase("true")); } } }
Example 2
Source File: UrlTriePrefixGrouper.java From incubator-gobblin with Apache License 2.0 | 6 votes |
/** * Get the detailed pages under this group */ public static ArrayList<String> groupToPages(Triple<String, GoogleWebmasterFilter.FilterOperator, UrlTrieNode> group) { ArrayList<String> ret = new ArrayList<>(); if (group.getMiddle().equals(GoogleWebmasterFilter.FilterOperator.EQUALS)) { if (group.getRight().isExist()) { ret.add(group.getLeft()); } } else if (group.getMiddle().equals(GoogleWebmasterFilter.FilterOperator.CONTAINS)) { UrlTrie trie = new UrlTrie(group.getLeft(), group.getRight()); Iterator<Pair<String, UrlTrieNode>> iterator = new UrlTriePostOrderIterator(trie, 1); while (iterator.hasNext()) { Pair<String, UrlTrieNode> next = iterator.next(); if (next.getRight().isExist()) { ret.add(next.getLeft()); } } } return ret; }
Example 3
Source File: SqlgGraph.java From sqlg with MIT License | 6 votes |
@Override public Vertex addVertex(Object... keyValues) { if (this.tx().isInStreamingBatchMode()) { throw SqlgExceptions.invalidMode(String.format("Transaction is in %s, use streamVertex(Object ... keyValues)", this.tx().getBatchModeType().toString())); } if (this.tx().isInStreamingWithLockBatchMode()) { return internalStreamVertex(keyValues); } else { Triple<Map<String, PropertyType>, Map<String, Object>, Map<String, Object>> keyValueMapTriple = SqlgUtil.validateVertexKeysValues(this.sqlDialect, keyValues); final Pair<Map<String, Object>, Map<String, Object>> keyValueMapPair = Pair.of(keyValueMapTriple.getMiddle(), keyValueMapTriple.getRight()); final Map<String, PropertyType> columns = keyValueMapTriple.getLeft(); final String label = ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL); SchemaTable schemaTablePair = SchemaTable.from(this, label); this.tx().readWrite(); this.getTopology().threadWriteLock(); VertexLabel vertexLabel = this.getTopology().ensureVertexLabelExist(schemaTablePair.getSchema(), schemaTablePair.getTable(), columns); if (!vertexLabel.hasIDPrimaryKey()) { Preconditions.checkArgument(columns.keySet().containsAll(vertexLabel.getIdentifiers()), "identifiers must be present %s", vertexLabel.getIdentifiers()); } return new SqlgVertex(this, false, false, schemaTablePair.getSchema(), schemaTablePair.getTable(), keyValueMapPair); } }
Example 4
Source File: GalleryInitResult.java From Overchan-Android with GNU General Public License v3.0 | 6 votes |
@Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(initPosition); dest.writeInt(shouldWaitForPageLoaded ? 1 : 0); dest.writeInt(attachments.size()); for (Triple<AttachmentModel, String, String> tuple : attachments) { AttachmentModel attachment = tuple.getLeft(); dest.writeInt(attachment.type); dest.writeInt(attachment.size); dest.writeString(attachment.thumbnail); dest.writeString(attachment.path); dest.writeInt(attachment.width); dest.writeInt(attachment.height); dest.writeString(attachment.originalName); dest.writeInt(attachment.isSpoiler ? 1 : 0); dest.writeString(tuple.getMiddle()); dest.writeString(tuple.getRight()); } }
Example 5
Source File: ClientProxy.java From Better-Sprinting with Mozilla Public License 2.0 | 6 votes |
@Override public void migrateConfig(List<Triple<Character, String, String>> oldConfig){ for(Triple<Character, String, String> entry:oldConfig){ if (entry.getLeft() == 'B'){ BooleanValue value; switch(entry.getMiddle()){ case "disableMod": value = ClientSettings.disableMod; break; case "enableDoubleTap": value = ClientSettings.enableDoubleTap; break; case "enableAllDirs": value = ClientSettings.enableAllDirs; break; case "flyOnGround": value = ClientSettings.flyOnGround; break; default: continue; } BetterSprintingMod.config.set(value, entry.getRight().equalsIgnoreCase("true")); } else if (entry.getLeft() == 'I' && entry.getMiddle().equals("flySpeedBoost")){ BetterSprintingMod.config.set(ClientSettings.flySpeedBoost, Integer.parseInt(entry.getRight())); } else if (entry.getLeft() == 'S' && entry.getMiddle().equals("sprintKeyMode") && entry.getRight().equals("HOLD")){ BetterSprintingMod.config.set(ClientSettings.sprintKeyMode, SprintKeyMode.HOLD); } } }
Example 6
Source File: AesCbcHmacSha2.java From azure-keyvault-java with MIT License | 6 votes |
AesCbcHmacSha2Encryptor(String name, byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { // Split the key to get the AES key, the HMAC key and the HMAC // object Triple<byte[], byte[], Mac> parameters = GetAlgorithmParameters(name, key); // Save the MAC provider and key _hmac = parameters.getRight(); _hmac_key = parameters.getMiddle(); // Create the AES encryptor _inner = new AesCbc.AesCbcEncryptor(parameters.getLeft(), iv, provider); _aad_length = toBigEndian(authenticationData.length * 8); // Prime the hash. _hmac.update(authenticationData); _hmac.update(iv); }
Example 7
Source File: SqlgGraph.java From sqlg with MIT License | 6 votes |
private SqlgVertex internalStreamVertex(Object... keyValues) { Preconditions.checkState(this.sqlDialect.supportsStreamingBatchMode(), "Streaming batch mode is not supported."); final String label = ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL); SchemaTable schemaTablePair = SchemaTable.from(this, label); SchemaTable streamingBatchModeVertexSchemaTable = this.tx().getBatchManager().getStreamingBatchModeVertexSchemaTable(); if (streamingBatchModeVertexSchemaTable != null && !streamingBatchModeVertexSchemaTable.toString().equals(schemaTablePair.toString())) { throw new IllegalStateException("Streaming batch mode must occur for one label at a time. Expected \"" + streamingBatchModeVertexSchemaTable + "\" found \"" + label + "\". First commit the transaction or call SqlgGraph.flush() before streaming a different label"); } List<String> keys = this.tx().getBatchManager().getStreamingBatchModeVertexKeys(); Triple<Map<String, PropertyType>, Map<String, Object>, Map<String, Object>> keyValueMapTriple = SqlgUtil.validateVertexKeysValues(this.sqlDialect, keyValues, keys); final Pair<Map<String, Object>, Map<String, Object>> keyValueMapPair = Pair.of(keyValueMapTriple.getMiddle(), keyValueMapTriple.getRight()); final Map<String, PropertyType> columns = keyValueMapTriple.getLeft(); this.tx().readWrite(); this.getTopology().ensureVertexLabelExist(schemaTablePair.getSchema(), schemaTablePair.getTable(), columns); return new SqlgVertex(this, false, true, schemaTablePair.getSchema(), schemaTablePair.getTable(), keyValueMapPair); }
Example 8
Source File: LearnReadOrientationModelEngineUnitTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
private List<AltSiteRecord> createDesignMatrixOfSingleContext(final Triple<String, Nucleotide, ReadOrientation> transition, final int refDepth, final int altDepth, final int refF1R2, final int altF1R2, final int numExamples) { final List<AltSiteRecord> altDesignMatrix = new ArrayList<>(numExamples); final String refContext = transition.getLeft(); final Nucleotide altAllele = transition.getMiddle(); IntStream.range(0, numExamples).forEach(i -> altDesignMatrix.add(new AltSiteRecord(refContext, refDepth, altDepth, refF1R2, altF1R2, altAllele))); return altDesignMatrix; }
Example 9
Source File: CaptionTextImporter.java From cineast with MIT License | 5 votes |
@Override public Map<String, PrimitiveTypeProvider> convert(Triple<String, String, String> data) { final HashMap<String, PrimitiveTypeProvider> map = new HashMap<>(2); String id = "v_" + data.getLeft() + "_" + data.getMiddle(); map.put(SimpleFulltextFeatureDescriptor.FIELDNAMES[0], PrimitiveTypeProvider.fromObject(id)); map.put(SimpleFulltextFeatureDescriptor.FIELDNAMES[1], PrimitiveTypeProvider.fromObject(data.getRight())); return map; }
Example 10
Source File: ItemBreakingTracker.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void onItemBroken(PlayerEntity player, ItemStack stack) { int scrappingLevel = EnchantmentHelper.getEnchantmentLevel(SurvivalistMod.SCRAPING.get(), stack); if (player.getClass().getName().equals("com.rwtema.extrautils2.fakeplayer.XUFakePlayer")) return; boolean fortune = rnd.nextDouble() > 0.9 / (1 + scrappingLevel); ItemStack ret = null; for (Triple<ItemStack, ItemStack, ItemStack> scraping : scrapingRegistry) { ItemStack source = scraping.getLeft(); if (source.getItem() != stack.getItem()) continue; ItemStack good = scraping.getMiddle(); ItemStack bad = scraping.getRight(); ret = fortune ? good.copy() : bad.copy(); break; } if (ret != null) { SurvivalistMod.LOGGER.debug("Item broke (" + stack + ") and the player got " + ret + " in return!"); SurvivalistMod.channel.sendTo(new ScrapingMessage(stack, ret), ((ServerPlayerEntity) player).connection.netManager, NetworkDirection.PLAY_TO_CLIENT); ItemHandlerHelper.giveItemToPlayer(player, ret); } }
Example 11
Source File: ConsulRegistryService.java From saluki with Apache License 2.0 | 5 votes |
private List<GrpcService> buildQueryResponse(Set<String> queryCondition, Boolean accurate) { List<GrpcService> services = Lists.newArrayList(); Map<String, Pair<Set<GrpcHost>, Set<GrpcHost>>> servicesPassing = registryRepository.getAllPassingService(); for (Iterator<String> it = queryCondition.iterator(); it.hasNext();) { String serviceKey = it.next(); Triple<String, String, String> appNameServiceVersion = getAppNameServiceVersion(serviceKey); Pair<Set<GrpcHost>, Set<GrpcHost>> providerConsumer = servicesPassing.get(serviceKey); GrpcService service = new GrpcService(appNameServiceVersion.getLeft(), appNameServiceVersion.getRight(), appNameServiceVersion.getMiddle()); service.setProviderHost(providerConsumer.getLeft()); service.setConsumerHost(providerConsumer.getRight()); services.add(service); } return services; }
Example 12
Source File: GalleryInitResult.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
public int getParcelSize() { int total = 12; for (Triple<AttachmentModel, String, String> tuple : attachments) { total += 40; AttachmentModel attachment = tuple.getLeft(); String hash = tuple.getMiddle(); String post = tuple.getRight(); if (attachment.thumbnail != null) total += attachment.thumbnail.length()*2; if (attachment.path != null) total += attachment.path.length()*2; if (attachment.originalName != null) total += attachment.originalName.length()*2; if (hash != null) total += hash.length()*2; if (post != null) total += post.length()*2; } return total; }
Example 13
Source File: TabsTrackerService.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
private static int findTab(List<Triple<String, String, String>> list, String tabUrl, String tabTitle) { for (int i=0; i<list.size(); ++i) { Triple<String, String, String> triple = list.get(i); if (tabUrl == null) { if (triple.getLeft() == null && tabTitle.equals(triple.getRight())) { return i; } } else { if (tabUrl.equals(triple.getLeft())) { return i; } } } return -1; }
Example 14
Source File: SqlgVertex.java From sqlg with MIT License | 5 votes |
private Edge addEdgeInternal(boolean complete, String label, Vertex inVertex, Object... keyValues) { if (null == inVertex) throw Graph.Exceptions.argumentCanNotBeNull("vertex"); if (this.removed) { throw new IllegalStateException(String.format("Vertex with id %s was removed.", id().toString())); } ElementHelper.validateLabel(label); Preconditions.checkArgument(!label.contains("."), String.format("Edge label may not contain a '.' , the edge will be stored in the schema of the owning vertex. label = %s", label)); ElementHelper.legalPropertyKeyValueArray(keyValues); if (ElementHelper.getIdValue(keyValues).isPresent()) throw Edge.Exceptions.userSuppliedIdsNotSupported(); List<String> previousBatchModeKeys; if (complete) { previousBatchModeKeys = this.sqlgGraph.tx().getBatchManager().getStreamingBatchModeEdgeKeys(); } else { previousBatchModeKeys = Collections.emptyList(); } Triple<Map<String, PropertyType>, Map<String, Object>, Map<String, Object>> keyValueMapTriple = SqlgUtil.validateVertexKeysValues(this.sqlgGraph.getSqlDialect(), keyValues, previousBatchModeKeys); if (!complete && keyValueMapTriple.getRight().size() != keyValueMapTriple.getMiddle().size()) { throw Property.Exceptions.propertyValueCanNotBeNull(); } final Pair<Map<String, Object>, Map<String, Object>> keyValueMapPair = Pair.of(keyValueMapTriple.getMiddle(), keyValueMapTriple.getRight()); final Map<String, PropertyType> columns = keyValueMapTriple.getLeft(); Optional<VertexLabel> outVertexLabelOptional = this.sqlgGraph.getTopology().getVertexLabel(this.schema, this.table); Optional<VertexLabel> inVertexLabelOptional = this.sqlgGraph.getTopology().getVertexLabel(((SqlgVertex) inVertex).schema, ((SqlgVertex) inVertex).table); Preconditions.checkState(outVertexLabelOptional.isPresent(), "Out VertexLabel must be present. Not found for %s", this.schema + "." + this.table); Preconditions.checkState(inVertexLabelOptional.isPresent(), "In VertexLabel must be present. Not found for %s", ((SqlgVertex) inVertex).schema + "." + ((SqlgVertex) inVertex).table); this.sqlgGraph.getTopology().threadWriteLock(); //noinspection OptionalGetWithoutIsPresent EdgeLabel edgeLabel = this.sqlgGraph.getTopology().ensureEdgeLabelExist(label, outVertexLabelOptional.get(), inVertexLabelOptional.get(), columns); if (!edgeLabel.hasIDPrimaryKey()) { Preconditions.checkArgument(columns.keySet().containsAll(edgeLabel.getIdentifiers()), "identifiers must be present %s", edgeLabel.getIdentifiers()); } return new SqlgEdge(this.sqlgGraph, complete, this.schema, label, (SqlgVertex) inVertex, this, keyValueMapPair); }
Example 15
Source File: TicketHelper.java From alf.io with GNU General Public License v3.0 | 5 votes |
private Triple<ValidationResult, Event, Ticket> assignTicket(UpdateTicketOwnerForm updateTicketOwner, Optional<Errors> bindingResult, Locale fallbackLocale, Optional<UserDetails> userDetails, Triple<Event, TicketReservation, Ticket> result, String formPrefix) { Ticket t = result.getRight(); final Event event = result.getLeft(); if(t.getLockedAssignment()) { //in case of locked assignment, fullName and Email will be overwritten updateTicketOwner.setFirstName(t.getFirstName()); updateTicketOwner.setLastName(t.getLastName()); updateTicketOwner.setFullName(t.getFullName()); updateTicketOwner.setEmail(t.getEmail()); } final TicketReservation ticketReservation = result.getMiddle(); List<TicketFieldConfiguration> fieldConf = ticketFieldRepository.findAdditionalFieldsForEvent(event.getId()); var sameCountryValidator = new SameCountryValidator(configurationManager, extensionManager, event, ticketReservation.getId(), vatChecker); AdvancedTicketAssignmentValidator advancedValidator = new AdvancedTicketAssignmentValidator(sameCountryValidator, new GroupManager.WhitelistValidator(event.getId(), groupManager)); var additionalServiceIds = new HashSet<>(additionalServiceItemRepository.findAdditionalServiceIdsByReservationUuid(t.getTicketsReservationId())); var ticketFieldFilterer = new Validator.TicketFieldsFilterer(fieldConf, ticketUUID -> t.getCategoryId(), additionalServiceIds, ticketRepository.findFirstTicketInReservation(t.getTicketsReservationId())); Validator.AdvancedValidationContext context = new Validator.AdvancedValidationContext(updateTicketOwner, fieldConf, t.getCategoryId(), t.getUuid(), formPrefix); ValidationResult validationResult = Validator.validateTicketAssignment(updateTicketOwner, ticketFieldFilterer.getFieldsForTicket(t.getUuid()), bindingResult, event, formPrefix, sameCountryValidator) .or(Validator.performAdvancedValidation(advancedValidator, context, bindingResult.orElse(null))) .ifSuccess(() -> updateTicketOwner(updateTicketOwner, fallbackLocale, t, event, ticketReservation, userDetails)); return Triple.of(validationResult, event, ticketRepository.findByUUID(t.getUuid())); }
Example 16
Source File: Reddit.java From Slide with GNU General Public License v3.0 | 5 votes |
public void setupNotificationChannels() { if (SDK_INT >= android.os.Build.VERSION_CODES.O) { // Each triple contains the channel ID, name, and importance level List<Triple<String, String, Integer>> notificationTripleList = new ArrayList<Triple<String, String, Integer>>() {{ add(Triple.of(CHANNEL_IMG, "Image downloads", NotificationManager.IMPORTANCE_LOW)); add(Triple.of(CHANNEL_COMMENT_CACHE, "Comment caching", NotificationManager.IMPORTANCE_LOW)); add(Triple.of(CHANNEL_MAIL, "Reddit mail", NotificationManager.IMPORTANCE_HIGH)); add(Triple.of(CHANNEL_MODMAIL, "Reddit modmail", NotificationManager.IMPORTANCE_HIGH)); add(Triple.of(CHANNEL_SUBCHECKING, "Submission post checking", NotificationManager.IMPORTANCE_LOW)); }}; NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); for (Triple<String, String, Integer> notificationTriple : notificationTripleList) { NotificationChannel notificationChannel = new NotificationChannel(notificationTriple.getLeft(), notificationTriple.getMiddle(), notificationTriple.getRight()); notificationChannel.enableLights(true); notificationChannel.setShowBadge( notificationTriple.getRight() == NotificationManager.IMPORTANCE_HIGH); notificationChannel.setLightColor( notificationTriple.getLeft().contains("MODMAIL") ? getResources().getColor( R.color.md_red_500, null) : Palette.getColor("")); if (notificationManager != null) { notificationManager.createNotificationChannel(notificationChannel); } } } }
Example 17
Source File: AdminReservationApiController.java From alf.io with GNU General Public License v3.0 | 5 votes |
private TicketReservationDescriptor toReservationDescriptor(String reservationId, Triple<TicketReservation, List<Ticket>, Event> triple) { List<SerializablePair<TicketCategory, List<Ticket>>> tickets = triple.getMiddle().stream().collect(Collectors.groupingBy(Ticket::getCategoryId)).entrySet().stream() .map(entry -> SerializablePair.of(eventManager.getTicketCategoryById(entry.getKey(), triple.getRight().getId()), entry.getValue())) .collect(Collectors.toList()); TicketReservation reservation = triple.getLeft(); return new TicketReservationDescriptor(reservation, ticketReservationManager.loadAdditionalInfo(reservationId), ticketReservationManager.orderSummaryForReservationId(reservationId, triple.getRight()), tickets); }
Example 18
Source File: SqlgStartupManager.java From sqlg with MIT License | 4 votes |
private void extractProperty(String schema, String table, String columnName, Integer columnType, String typeName, Map<String, PropertyType> columns, ListIterator<Triple<String, Integer, String>> metaDataIter) { //check for ZONEDDATETIME, PERIOD, DURATION as they use more than one field to represent the type PropertyType propertyType = null; if (metaDataIter.hasNext()) { Triple<String, Integer, String> column2MetaData = metaDataIter.next(); String column2Name = column2MetaData.getLeft(); String typeName2 = column2MetaData.getRight(); int column2Type = column2MetaData.getMiddle(); if (column2Name.startsWith(columnName + "~~~")) { if (column2Type == Types.VARCHAR) { propertyType = PropertyType.ZONEDDATETIME; } else if ((column2Type == Types.ARRAY && this.sqlDialect.sqlArrayTypeNameToPropertyType(typeName2, this.sqlgGraph, schema, table, column2Name, metaDataIter) == PropertyType.STRING_ARRAY)) { propertyType = PropertyType.ZONEDDATETIME_ARRAY; } else { if (metaDataIter.hasNext()) { Triple<String, Integer, String> column3MetaData = metaDataIter.next(); String column3Name = column3MetaData.getLeft(); String typeName3 = column3MetaData.getRight(); int column3Type = column3MetaData.getMiddle(); if (column3Name.startsWith(columnName + "~~~")) { if (column3Type == Types.ARRAY) { Preconditions.checkState(sqlDialect.sqlArrayTypeNameToPropertyType(typeName3, this.sqlgGraph, schema, table, column3Name, metaDataIter) == PropertyType.INTEGER_ARRAY, "Only Period have a third column and it must be a Integer"); propertyType = PropertyType.PERIOD_ARRAY; } else { Preconditions.checkState(column3Type == Types.INTEGER, "Only Period have a third column and it must be a Integer"); propertyType = PropertyType.PERIOD; } } else { metaDataIter.previous(); if (column2Type == Types.ARRAY) { Preconditions.checkState(sqlDialect.sqlArrayTypeNameToPropertyType(typeName2, this.sqlgGraph, schema, table, column2Name, metaDataIter) == PropertyType.INTEGER_ARRAY, "Only Period have a third column and it must be a Integer"); propertyType = PropertyType.DURATION_ARRAY; } else { Preconditions.checkState(column2Type == Types.INTEGER, "Only Duration and Period have a second column and it must be a Integer"); propertyType = PropertyType.DURATION; } } } } } else { metaDataIter.previous(); } } if (propertyType == null) { propertyType = this.sqlDialect.sqlTypeToPropertyType(this.sqlgGraph, schema, table, columnName, columnType, typeName, metaDataIter); } columns.put(columnName, propertyType); }
Example 19
Source File: FreeMarkerTemplateRendererBuilder.java From youran with Apache License 2.0 | 4 votes |
@Override public TemplateRenderer buildRenderer(CodeTemplatePO templatePO) { Triple<Configuration, Integer, String> triple = freeMarkerConfigFactory.getConfigurationTriple(templatePO); FreeMarkerRenderer renderer = new FreeMarkerRenderer(triple.getLeft(), triple.getRight()); return renderer; }
Example 20
Source File: LearnReadOrientationModelIntegrationTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Test that the tool sites of orientation bias that are manually picked out. * Also tests scattering CollectF1R2Counts */ @Test(dataProvider = "scatterCounts") public void testOnRealBam(final int scatterCount) throws IOException { final File scatteredDir = createTempDir("scattered"); // Step 1: SplitIntervals final File intervalDir = createTempDir("intervals"); final ArgumentsBuilder splitIntervalsArgs = new ArgumentsBuilder() .addReference(b37Reference) .addIntervals(new File(intervalList)) .addOutput(intervalDir) .add(SplitIntervals.SCATTER_COUNT_SHORT_NAME, scatterCount); runCommandLine(splitIntervalsArgs, SplitIntervals.class.getSimpleName()); // Step 2: CollectF1R2Counts final File[] intervals = intervalDir.listFiles(); final List<File> extractedDirs = IntStream.range(0, intervals.length).mapToObj(i -> createTempDir("extracted_" + i)).collect(Collectors.toList()); final List<File> scatteredTarGzs = IntStream.range(0, intervals.length).mapToObj(i -> new File(scatteredDir, "scatter_" + i + ".tar.gz")).collect(Collectors.toList()); for (int i = 0; i < intervals.length; i++){ final ArgumentsBuilder collectF1R2CountsArgs = new ArgumentsBuilder() .addReference(b37Reference) .addInput(new File(hapmapBamSnippet)) .addIntervals(intervals[i]) .addOutput(scatteredTarGzs.get(i)); runCommandLine(collectF1R2CountsArgs, CollectF1R2Counts.class.getSimpleName()); IOUtils.extractTarGz(scatteredTarGzs.get(i).toPath(), extractedDirs.get(i).toPath()); final File refHist = F1R2CountsCollector.getRefHistogramsFromExtractedTar(extractedDirs.get(i)).get(0); // Ensure that we print every bin, even when the count is 0 final int lineCount = (int) Files.lines(Paths.get(refHist.getAbsolutePath())).filter(l -> l.matches("^[0-9].+")).count(); Assert.assertEquals(lineCount, F1R2FilterConstants.DEFAULT_MAX_DEPTH); } // Step 3: LearnReadOrientationModel final File priorTarGz = createTempFile("prior", ".tar.gz"); final ArgumentsBuilder args = new ArgumentsBuilder() .addOutput(priorTarGz); IntStream.range(0, intervals.length).forEach(n -> args.addInput(scatteredTarGzs.get(n))); runCommandLine(args.getArgsList(), LearnReadOrientationModel.class.getSimpleName()); final File extractedPriorDir = createTempDir("extracted_priors"); IOUtils.extractTarGz(priorTarGz.toPath(), extractedPriorDir.toPath()); final ArtifactPriorCollection artifactPriorCollection = ArtifactPriorCollection.readArtifactPriors(extractedPriorDir.listFiles()[0]); // Step 4: Mutect 2 final File unfilteredVcf = GATKBaseTest.createTempFile("unfiltered", ".vcf"); final File filteredVcf = GATKBaseTest.createTempFile("filtered", ".vcf"); final File bamout = GATKBaseTest.createTempFile("SM-CEMAH", ".bam"); final ArgumentsBuilder mutect2Args = new ArgumentsBuilder() .addReference(b37Reference) .addInput(new File(hapmapBamSnippet)) .addOutput(unfilteredVcf) .add(AssemblyBasedCallerArgumentCollection.BAM_OUTPUT_LONG_NAME, bamout); runCommandLine(mutect2Args, Mutect2.class.getSimpleName()); final ArgumentsBuilder filterArgs = new ArgumentsBuilder() .addReference(b37Reference) .addVCF(unfilteredVcf) .add(M2FiltersArgumentCollection.ARTIFACT_PRIOR_TABLE_NAME, priorTarGz) .addOutput(filteredVcf); runCommandLine(filterArgs, FilterMutectCalls.class.getSimpleName()); // These artifacts have been verified manually // The pair is of type (Position, Expected Source of Prior Probability) // Prior for e.g. TGA->A F2R1 should come from TCA->T F1R2 final List<Triple<Integer, ReadOrientation, ArtifactState>> knownArtifacts = Arrays.asList( new ImmutableTriple<>(23421079, ReadOrientation.F2R1, ArtifactState.F2R1_G), // CAC->G F2R1 new ImmutableTriple<>(34144749, ReadOrientation.F2R1, ArtifactState.F2R1_A), // TGA->A F2R1, ref context is not canonical new ImmutableTriple<>(62165528, ReadOrientation.F1R2, ArtifactState.F1R2_A)); // CGC->A F1R2 for (final Triple<Integer, ReadOrientation, ArtifactState> artifact : knownArtifacts) { final int position = artifact.getLeft(); Optional<VariantContext> variant = StreamSupport.stream(new FeatureDataSource<VariantContext>(filteredVcf).spliterator(), false) .filter(vc -> vc.getStart() == position).findFirst(); Assert.assertTrue(variant.isPresent()); // Check that the expected filters were applied Assert.assertTrue(variant.get().getFilters().contains(GATKVCFConstants.READ_ORIENTATION_ARTIFACT_FILTER_NAME)); } }