private GCBin.GCResult getBin(String chr, int gcContent) {
   for (Location loc : GCBins.keySet()) {
     if (loc.getChromosome().equals(chr) && loc.containsLocation(gcContent))
       return GCBins.get(loc);
   }
   return null;
 }
Beispiel #2
0
  @Override
  public DNASequence mutateSequence(String sequence, int count) {
    lastMutations = new LinkedHashMap<Location, DNASequence>();

    for (int i = 0; i < count; i++) {
      int size = this.getRandomVarLength();
      if (size >= sequence.length()) continue;

      int siteStart = getStartSite(sequence.length(), size);

      Location newLoc = new Location(siteStart, siteStart + size);

      // need to exclude previous sites
      for (Location loc : lastMutations.keySet()) {
        while (loc.overlapsLocation(newLoc)) {
          siteStart = getStartSite(sequence.length(), size);
          newLoc = new Location(siteStart, siteStart + size);
        }
      }

      String copySeq = sequence.substring(siteStart - size, siteStart);

      StringBuffer buf = new StringBuffer();
      buf.append(sequence.substring(0, siteStart));
      buf.append(copySeq);
      buf.append(sequence.substring(siteStart, sequence.length()));

      sequence = buf.toString();

      lastMutations.put(new Location(siteStart, siteStart + size), new DNASequence(sequence));
    }

    return new DNASequence(sequence);
  }