Java BigInteger to convertToString(BigInteger biSequence, int kmerSize)

Here you can find the source of convertToString(BigInteger biSequence, int kmerSize)

Description

convert To String

License

Apache License

Declaration

public static String convertToString(BigInteger biSequence, int kmerSize) 

Method Source Code

//package com.java2s;
/*/*from www  . ja va2  s. co  m*/
 * Copyright 2015 iychoi.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.math.BigInteger;

public class Main {
    public static String convertToString(BigInteger biSequence, int kmerSize) {
        String str = "";
        for (int i = 0; i < kmerSize; i++) {
            int idx = biSequence.mod(BigInteger.valueOf(4)).intValue();
            if (idx == 0) {
                str = "A" + str;
            } else if (idx == 1) {
                str = "C" + str;
            } else if (idx == 2) {
                str = "G" + str;
            } else if (idx == 3) {
                str = "T" + str;
            }
            biSequence = biSequence.divide(BigInteger.valueOf(4));
        }

        return str;
    }
}

Related

  1. convertPositive(BigInteger bi)
  2. convertRealNumberBits(BigInteger source, int size, int direction)
  3. convertRepresentation(BigInteger b)
  4. convertToBase62String(BigInteger value)
  5. convertToLong(BigInteger bigInteger)
  6. convertValueToZeroIfNullOrNegative(BigInteger value)
  7. getUnsignedBigIntegerAsHex(BigInteger bi)
  8. getUnsignedBytes(BigInteger number, int length)
  9. stringForBig(BigInteger big, int sigchars)