Ejemplo n.º 1
0
  /** Is 'fieldName' a per-allele annotation */
  boolean isVcfInfoPerAllele(String fieldName) {
    // Look up information and cache it
    if (vcfInfoPerAllele.get(fieldName) == null) {
      VcfHeaderInfo vcfInfo = dbVcf.getVcfHeader().getVcfInfo(fieldName);
      boolean isPerAllele =
          vcfInfo != null && (vcfInfo.isNumberOnePerAllele() || vcfInfo.isNumberAllAlleles());
      vcfInfoPerAllele.put(fieldName, isPerAllele);
    }

    return vcfInfoPerAllele.get(fieldName);
  }
Ejemplo n.º 2
0
  /** Is this a "per-allele + REF" INFO field? */
  boolean isVcfInfoPerAlleleRef(String fieldName) {
    // Look up information and cache it
    if (vcfInfoPerAlleleRef.get(fieldName) == null) {
      VcfHeaderInfo vcfInfo = dbVcf.getVcfHeader().getVcfInfo(fieldName);
      boolean isPerAlleleRef = (vcfInfo != null && vcfInfo.isNumberAllAlleles());
      vcfInfoPerAlleleRef.put(fieldName, isPerAlleleRef);

      hasVcfInfoPerAlleleRef |=
          isPerAlleleRef; // Do we have any INFO field requiring 'REF' annotation?
    }

    return vcfInfoPerAlleleRef.get(fieldName);
  }
Ejemplo n.º 3
0
  protected void discoverInfoFields() {
    if (infoFields == null) infoFields = new HashSet<String>();

    // Discover some INFO fields
    if (!useAllInfoFields) return;

    // Find INFO form VcfHeader
    if (dbVcf != null && dbVcf.getVcfHeader() != null) {
      for (VcfHeaderInfo vcfInfo : dbVcf.getVcfHeader().getVcfInfo()) {

        // Don't add implicit fields at this stage
        // Note: They are added if they are found in a VCF entry later
        if (!vcfInfo.isImplicit()) {
          String infoFieldName = vcfInfo.getId();
          infoFields.add(infoFieldName);

          // Cache values for future use
          isVcfInfoPerAllele(infoFieldName);
          isVcfInfoPerAlleleRef(infoFieldName);
        }
      }
    }
  }
Ejemplo n.º 4
0
  /** Query database and find results matching 'variant' */
  protected Collection<VariantVcfEntry> query(Variant variant) {
    // Query database
    Collection<VariantVcfEntry> results = dbVcf.query(variant);

    // Filter results to match 'variant'
    List<VariantVcfEntry> list = new LinkedList<>();
    for (VariantVcfEntry dbEntry : results) {
      if (match(variant, dbEntry)) {
        if (debug)
          Gpr.debug("dbEntry matches query\tvariant: " + variant + "\tdbEntry: " + dbEntry);
        list.add(dbEntry);
      } else {
        if (debug)
          Gpr.debug("dbEntry does NOT match query\tvariant: " + variant + "\tdbEntry: " + dbEntry);
      }
    }

    if (debug) Gpr.debug("Match query results: " + list.size());
    return list;
  }
Ejemplo n.º 5
0
 public void setVerbose(boolean verbose) {
   this.verbose = verbose;
   dbVcf.setVerbose(verbose);
 }
Ejemplo n.º 6
0
 public void setDebug(boolean debug) {
   this.debug = debug;
   dbVcf.setDebug(debug);
 }
Ejemplo n.º 7
0
 public void open() {
   dbVcf.open();
   discoverInfoFields();
 }
Ejemplo n.º 8
0
 public void close() {
   dbVcf.close();
 }