From 5e96ab61619a236db049bcfd85177ab40ef7673a Mon Sep 17 00:00:00 2001 From: kiran Date: Mon, 13 Apr 2009 00:46:23 +0000 Subject: [PATCH] Helpful functions for converting a base (char) to a base index (A:0, C:1, G:2, T:3, alphabetical and consistent with Illumina conventions to minimize confusion. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@373 348d0f76-0448-11de-a6fe-93d51630548a --- .../broadinstitute/sting/utils/BaseUtils.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 java/src/org/broadinstitute/sting/utils/BaseUtils.java diff --git a/java/src/org/broadinstitute/sting/utils/BaseUtils.java b/java/src/org/broadinstitute/sting/utils/BaseUtils.java new file mode 100644 index 000000000..b4f3b4d2f --- /dev/null +++ b/java/src/org/broadinstitute/sting/utils/BaseUtils.java @@ -0,0 +1,31 @@ +package org.broadinstitute.sting.utils; + +public class BaseUtils { + static public int simpleBaseToBaseIndex(char base) { + switch (base) { + case 'A': + case 'a': return 0; + + case 'C': + case 'c': return 1; + + case 'G': + case 'g': return 2; + + case 'T': + case 't': return 3; + + default: return -1; + } + } + + static public char baseIndexToSimpleBase(int baseIndex) { + switch (baseIndex) { + case 0: return 'A'; + case 1: return 'C'; + case 2: return 'G'; + case 3: return 'T'; + default: return '.'; + } + } +}