All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.charite.compbio.jannovar.reference.DuplicationChecker Maven / Gradle / Ivy

There is a newer version: 0.41
Show newest version
package de.charite.compbio.jannovar.reference;

/**
 * Helper class for checking whether an insertion in a string is a duplication.
 *
 * @author Manuel Holtgrewe
 */
public final class DuplicationChecker {

	/**
	 * @param ref
	 *            reference string for insertion
	 * @param insertion
	 *            the string to be inserted at pos
	 * @param pos
	 *            the 0-based position in ref that insertion is to be inserted
	 *
	 * @return true if the described insertion is a duplication
	 */
	public static boolean isDuplication(String ref, String insertion, int pos) {
		if (pos + insertion.length() <= ref.length()) {
			// can be duplication with string after pos
			if (ref.substring(pos, pos + insertion.length()).equals(insertion))
				return true;
		}
		if (pos >= insertion.length()) {
			// can be duplication with string before pos
			if (ref.substring(pos - insertion.length(), pos).equals(insertion))
				return true;
		}
		return false;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy