Ejemplo n.º 1
0
  public Collection<NamedRegion> parseProbes() throws IOException {
    double ethreshold = 1.0e-3;
    Parser<BlastTabEntry> parser =
        new Parser<BlastTabEntry>(blasttab, new BlastTabEntry.ParsingMapper());
    Iterator<BlastTabEntry> itr =
        new FilterIterator<BlastTabEntry, BlastTabEntry>(
            new BlastTabEntry.ExpectedScoreFilter(ethreshold), parser);

    Map<String, Set<Region>> primerHits = new TreeMap<String, Set<Region>>();
    Set<String> primerNames = new TreeSet<String>();

    while (itr.hasNext()) {
      BlastTabEntry entry = itr.next();
      NamedRegion r = createNamedRegion(entry);
      if (!primerHits.containsKey(entry.getQuery())) {
        primerHits.put(entry.getQuery(), new HashSet<Region>());
      }
      primerHits.get(entry.getQuery()).add(r);
      primerNames.add(removePrimerLR(entry.getQuery()));
    }

    LinkedList<NamedRegion> probes = new LinkedList<NamedRegion>();

    for (String primerName : primerNames) {
      Pair<Region, Region> hits = findProbePair(primerName, primerHits);
      if (hits != null) {
        Region left = hits.getFirst(), right = hits.getLast();
        int start = Math.min(left.getStart(), right.getStart());
        int end = Math.max(left.getEnd(), right.getEnd());

        NamedRegion probe = new NamedRegion(genome, left.getChrom(), start, end, primerName);
        probes.addLast(probe);
      }
    }

    return probes;
  }
Ejemplo n.º 2
0
 public NamedRegion createNamedRegion(BlastTabEntry e) {
   int start = Math.min(e.getSubjectStart(), e.getSubjectEnd());
   int end = Math.max(e.getSubjectStart(), e.getSubjectEnd());
   String chrom = getChrom(e.getSubject());
   return new NamedRegion(genome, chrom, start, end, e.getQuery());
 }
Ejemplo n.º 3
0
  public static void main(String args[]) throws Exception {
    Genome genome = Args.parseGenome(args).cdr();
    ChipChipDataset dataset = new ChipChipDataset(genome);
    List<Region> regions = Args.parseRegionsOrDefault(args);

    double means[] = new double[CGHCallExpander.numStates],
        stddevs[] = new double[CGHCallExpander.numStates];
    String[] pieces =
        Args.parseString(
                args,
                "low",
                String.format(
                    "%f;%f",
                    CGHCallExpander.defaultParams[0][0],
                    Math.sqrt(CGHCallExpander.defaultParams[0][1])))
            .split(";");
    means[CGHCallExpander.LOW] = Double.parseDouble(pieces[0]);
    stddevs[CGHCallExpander.LOW] = Math.pow(Double.parseDouble(pieces[1]), 2);

    pieces =
        Args.parseString(
                args,
                "middle",
                String.format(
                    "%f;%f",
                    CGHCallExpander.defaultParams[0][0],
                    Math.sqrt(CGHCallExpander.defaultParams[0][1])))
            .split(";");
    means[CGHCallExpander.ONE] = Double.parseDouble(pieces[0]);
    stddevs[CGHCallExpander.ONE] = Math.pow(Double.parseDouble(pieces[1]), 2);

    pieces =
        Args.parseString(
                args,
                "high",
                String.format(
                    "%f;%f",
                    CGHCallExpander.defaultParams[0][0],
                    Math.sqrt(CGHCallExpander.defaultParams[0][1])))
            .split(";");
    means[CGHCallExpander.HIGH] = Double.parseDouble(pieces[0]);
    stddevs[CGHCallExpander.HIGH] = Math.pow(Double.parseDouble(pieces[1]), 2);

    for (ExptNameVersion env : Args.parseENV(args)) {
      ChipChipData ccd = dataset.getData(env);
      CGHCallExpander cgh = new CGHCallExpander(ccd);
      cgh.setStateParameters(
          CGHCallExpander.LOW, means[CGHCallExpander.LOW], stddevs[CGHCallExpander.LOW]);
      cgh.setStateParameters(
          CGHCallExpander.ONE, means[CGHCallExpander.ONE], stddevs[CGHCallExpander.ONE]);
      cgh.setStateParameters(
          CGHCallExpander.HIGH, means[CGHCallExpander.HIGH], stddevs[CGHCallExpander.HIGH]);
      cgh.resetHMM();
      for (Region r : regions) {
        List<ScoredRegion> calls = cgh.executeList(r);
        for (ScoredRegion call : calls) {
          System.out.println(call.getScore() + "\t" + call.regionString());
        }
      }
    }
  }