@Override public SeekableStream asUnbufferedSeekableStream() { return lazySeekableStream.get(); }
@Override public SeekableStream asUnbufferedSeekableStream() { return lazySeekableStream.get(); }
@Override public SeekableStream asUnbufferedSeekableStream() { return lazySeekableStream.get(); }
@Override public SeekableStream asUnbufferedSeekableStream() { return lazySeekableStream.get(); }
@Override public SeekableStream asUnbufferedSeekableStream() { return lazySeekableStream.get(); }
@Override public SeekableStream asUnbufferedSeekableStream() { return lazySeekableStream.get(); }
private FastqWriter getSecondOfPair() { return secondOfPair.get(); }
private FastqWriter getSecondOfPair() { return secondOfPair.get(); }
@Override public SeekableStream asUnbufferedSeekableStream() { //if the file doesn't exist, the try to open the stream anyway because users might be expecting the exception //if it not a regular file than we won't be able to seek on it, so return null if (!fileResource.exists() || fileResource.isFile()) { return lazySeekableStream.get(); } else { return null; } }
@Override public SeekableStream asUnbufferedSeekableStream() { //if the file doesn't exist, the try to open the stream anyway because users might be expecting the exception //if it not a regular file than we won't be able to seek on it, so return null if (!fileResource.exists() || fileResource.isFile()) { return lazySeekableStream.get(); } else { return null; } }
private void closeAll() { final Set<FastqWriter> fastqWriters = new HashSet<>(); fastqWriters.add(firstOfPair); fastqWriters.add(unpaired); // Make sure this is a no-op if the second writer was never fetched. if (secondOfPair.isInitialized()) { fastqWriters.add(secondOfPair.get()); } for (final FastqWriter fastqWriter : fastqWriters) { fastqWriter.close(); } } }
private MendelianViolationDetector buildDetector() { return new MendelianViolationDetector( ImmutableSet.copyOf(SKIP_CHROMS), ImmutableSet.copyOf(MALE_CHROMS), ImmutableSet.copyOf(FEMALE_CHROMS), MIN_HET_FRACTION, MIN_GQ, MIN_DP, generateTrioMetricsBase(), ImmutableList.copyOf(parIntervals.get()), progressLogger ); }
private void closeAll() { final Set<FastqWriter> fastqWriters = new HashSet<>(); fastqWriters.add(firstOfPair); fastqWriters.add(unpaired); // Make sure this is a no-op if the second writer was never fetched. if (secondOfPair.isInitialized()) { fastqWriters.add(secondOfPair.get()); } for (final FastqWriter fastqWriter : fastqWriters) { fastqWriter.close(); } } }
private MendelianViolationDetector buildDetector() { return new MendelianViolationDetector( ImmutableSet.copyOf(SKIP_CHROMS), ImmutableSet.copyOf(MALE_CHROMS), ImmutableSet.copyOf(FEMALE_CHROMS), MIN_HET_FRACTION, MIN_GQ, MIN_DP, generateTrioMetricsBase(), ImmutableList.copyOf(parIntervals.get()), progressLogger ); }
/** * Method for creating JexlVCMatchExp from input walker arguments mapping from names to exps. These two arrays contain * the name associated with each JEXL expression. initializeMatchExps will parse each expression and return * a list of JexlVCMatchExp, in order, that correspond to the names and exps. These are suitable input to * match() below. * * @param names_and_exps mapping of names to expressions * @return list of matches */ public static List<JexlVCMatchExp> initializeMatchExps(Map<String, String> names_and_exps) { List<JexlVCMatchExp> exps = new ArrayList<>(); for ( Map.Entry<String, String> elt : names_and_exps.entrySet() ) { String name = elt.getKey(); String expStr = elt.getValue(); if ( name == null || expStr == null ) throw new IllegalArgumentException("Cannot create null expressions : " + name + " " + expStr); try { Expression exp = engine.get().createExpression(expStr); exps.add(new JexlVCMatchExp(name, exp)); } catch (Exception e) { throw new IllegalArgumentException("Argument " + name + "has a bad value. Invalid expression used (" + expStr + "). Please see the JEXL docs for correct syntax.") ; } } return exps; }
/** * Method for creating JexlVCMatchExp from input walker arguments mapping from names to exps. These two arrays contain * the name associated with each JEXL expression. initializeMatchExps will parse each expression and return * a list of JexlVCMatchExp, in order, that correspond to the names and exps. These are suitable input to * match() below. * * @param names_and_exps mapping of names to expressions * @return list of matches */ public static List<JexlVCMatchExp> initializeMatchExps(Map<String, String> names_and_exps) { List<JexlVCMatchExp> exps = new ArrayList<JexlVCMatchExp>(); for ( Map.Entry<String, String> elt : names_and_exps.entrySet() ) { String name = elt.getKey(); String expStr = elt.getValue(); if ( name == null || expStr == null ) throw new IllegalArgumentException("Cannot create null expressions : " + name + " " + expStr); try { Expression exp = engine.get().createExpression(expStr); exps.add(new JexlVCMatchExp(name, exp)); } catch (Exception e) { throw new IllegalArgumentException("Argument " + name + "has a bad value. Invalid expression used (" + expStr + "). Please see the JEXL docs for correct syntax.") ; } } return exps; }
final List<MendelianViolationMetrics> metrics = new ArrayList<>(); for (final PedFile.PedTrio trio : pedFile.get().values()) { final MendelianViolationMetrics m = new MendelianViolationMetrics(); m.MOTHER = trio.getMaternalId(); final Set<String> allSamples = new HashSet<>(inputHeader.get().getSampleNamesInOrder()); final Iterator<MendelianViolationMetrics> trioIterator = metrics.iterator();
private void writeAllViolations(final MendelianViolationDetector.Result result) { if (VCF_DIR != null) { LOG.info(String.format("Writing family violation VCFs to %s/", VCF_DIR.getAbsolutePath())); final VariantContextComparator vcComparator = new VariantContextComparator(inputHeader.get().getContigLines()); final Set<VCFHeaderLine> headerLines = new LinkedHashSet<>(inputHeader.get().getMetaDataInInputOrder()); headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.MENDELIAN_VIOLATION_KEY, 1, VCFHeaderLineType.String, "Type of mendelian violation.")); headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.ORIGINAL_AC, VCFHeaderLineCount.A, VCFHeaderLineType.Integer, "Original AC")); headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.ORIGINAL_AF, VCFHeaderLineCount.A, VCFHeaderLineType.Float, "Original AF")); headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.ORIGINAL_AN, 1, VCFHeaderLineType.Integer, "Original AN")); for (final PedFile.PedTrio trio : pedFile.get().values()) { final File outputFile = new File(VCF_DIR, IOUtil.makeFileNameSafe(trio.getFamilyId() + IOUtil.VCF_FILE_EXTENSION)); LOG.info(String.format("Writing %s violation VCF to %s", trio.getFamilyId(), outputFile.getAbsolutePath())); final VariantContextWriter out = new VariantContextWriterBuilder() .setOutputFile(outputFile) .unsetOption(INDEX_ON_THE_FLY) .build(); final VCFHeader newHeader = new VCFHeader(headerLines, CollectionUtil.makeList(trio.getMaternalId(), trio.getPaternalId(), trio.getIndividualId())); final TreeSet<VariantContext> orderedViolations = new TreeSet<>(vcComparator); orderedViolations.addAll(result.violations().get(trio.getFamilyId())); out.writeHeader(newHeader); orderedViolations.forEach(out::add); out.close(); } } }
@Test public void testInvalidJexl() { // NOTE: JexlEngine singleton construction in VariantContextUtils sets silent to false. // However VariantFiltration.initialize() sets setSilent(true) on the shared instance. // Just in case this test runs after a VariantFiltration in the same VM, always set silent back to false. htsjdk.variant.variantcontext.VariantContextUtils.engine.get().setSilent(false); WalkerTestSpec spec = new WalkerTestSpec( "-T SelectVariants" + " -R "+b37KGReference + " -V "+privateTestDir+"ac0.vcf" + " -select 'vc.getGenotype(\"FAKE_SAMPLE\").isHomRef()'" + " -o %s", 1, UserException.class); executeTest("InvalidJexl", spec); }
@Override public void initialize() { if ( maskExtension < 0 ) { throw new UserException.BadArgumentValue("maskExtension", "negative values are not allowed"); } if (filterRecordsNotInMask && !mask.isBound()) { throw new UserException.BadArgumentValue("filterNotInMask", "argument not allowed if mask argument is not provided"); } if ( clusterWindow > 0 ) { clusteredSNPs = new ClusteredSnps(getToolkit().getGenomeLocParser(), clusterSize, clusterWindow); } filterExps = VariantContextUtils.initializeMatchExps(filterNames, filterExpressions); genotypeFilterExps = VariantContextUtils.initializeMatchExps(genotypeFilterNames, genotypeFilterExpressions); VariantContextUtils.engine.get().setSilent(true); initializeVcfWriter(); }