Translates sequence having length divisible by 3, starting from first nucleotide.

@param sequence nucleotide sequence
@return translated amino acid sequence
342415
public static AminoAcidSequence translate(NucleotideSequence sequence) {
        if (sequence.size() % 3 != 0)
            throw new IllegalArgumentException("Only nucleotide sequences with size multiple " +
                    "of three are supported (in-frame).");
        byte[] aaData = new byte[sequence.size() / 3];
        GeneticCode.translate(aaData, 0, sequence, 0, sequence.size());
        return new AminoAcidSequence(aaData, true);
    }
1064105
def coding_sequence(self):
        
        if self.sequence is None:
            return None

        start = self.first_start_codon_spliced_offset
        end = self.last_stop_codon_spliced_offset

        # If start codon is the at nucleotide offsets [3,4,5] and
        # stop codon is at nucleotide offsets  [20,21,22]
        # then start = 3 and end = 22.
        #
        # Adding 1 to end since Python uses non-inclusive ends in slices/ranges.

        # pylint: disable=invalid-slice-index
        # TODO(tavi) Figure out pylint is not happy with this slice
        return self.sequence[start:end + 1]
126247
public List<List<Writable>> transformRawStringsToInputSequence(List<List<String>> sequence) {
        List<List<Writable>> ret = new ArrayList<>();
        for(List<String> input : sequence)
            ret.add(transformRawStringsToInputList(input));
        return ret;
    }
598130
public function toASN1(): Sequence
    {
        $elements = array($this->_base->toASN1());
        if (isset($this->_min) && $this->_min != 0) {
            $elements[] = new ImplicitlyTaggedType(0, new Integer($this->_min));
        }
        if (isset($this->_max)) {
            $elements[] = new ImplicitlyTaggedType(1, new Integer($this->_max));
        }
        return new Sequence(...$elements);
    }
850754
public static <C extends Compound> SequenceView<C> createSubSequence(
			Sequence<C> sequence, int start, int end) {
		return new SequenceProxyView<C>(sequence, start, end);
	}
1294505
@Override
	public <C extends Compound> Sequence<C> getSubSequence(Sequence<C> sequence) {
		if(isCircular()) {
			List<Sequence<C>> sequences = new ArrayList<Sequence<C>>();
			for(Location l: this) {
				sequences.add(l.getSubSequence(sequence));
			}
			return new JoiningSequenceReader<C>(sequence.getCompoundSet(), sequences);
		}
		return reverseSequence(sequence.getSubSequence(
				getStart().getPosition(), getEnd().getPosition()));
	}
1101458
@Deprecated
	@Override
	public String getSequence(Long beginPosition, Long endPosition) {

		if (beginPosition == null || endPosition == null
				|| (beginPosition > endPosition) || beginPosition < 1
				|| endPosition >getLength()) {
			return null;
		}
		
       int length = (int) (endPosition.longValue() - beginPosition.longValue()) + 1;
	   int offset = beginPosition.intValue() - 1;
	   String subSequence=null;
		try{
			subSequence= ByteBufferUtils.string(getSequenceBuffer(), offset, length);
		}
		catch(Exception e)
		{
			e.printStackTrace();
			return subSequence;
		}
        return subSequence;
		/*// note begin:1 end:4 has length 4
		

		byte[] subsequence = new byte[length];

		
		synchronized (sequence) {
			sequence.position(offset);
			sequence.get(subsequence, 0, length);
		}
		
		String string = new String(subsequence);

		return string;*/
	}
250750
protected function readUntilSequence($sequence) {
        $buffer = '';

        // Optimization for reading larger blocks faster.
        $first = substr($sequence, 0, 1);
        while ($this->scanner->current() !== false) {
            $buffer .= $this->scanner->charsUntil($first);

            // Stop as soon as we hit the stopping condition.
            if ($this->sequenceMatches($sequence) || $this->sequenceMatches(strtoupper($sequence))) {
                return $buffer;
            }
            $buffer .= $this->scanner->current();
            $this->scanner->next();
        }

        // If we get here, we hit the EOF.
        $this->parseError("Unexpected EOF during text read.");
        return $buffer;
    }
1041335
public static CodepointMatcher anyOf(final String sequence) {
    switch (sequence.length()) {
      case 0:
        return none();
      case 1:
        return is(sequence);
      default:
        return new AnyOf(sequence);
    }
  }
1216017
public <T> List<T> reorder( List<T> sequence)
    {
    int elementCount = sequence.size();
    if( elementCount > 1)
      {
      List<T> elements = new ArrayList<T>( sequence);
      sequence.clear();

      for( ; elementCount > 0; elementCount--)
        {
        sequence.add( elements.remove( generator_.nextInt( elementCount)));
        }
      }

    return sequence;
    }
280356
public M sequence(String sequenceKey, SequenceConfig sequenceConfig) {
        getSequence(sequenceKey, firstNonNull(sequenceConfig, defaultSequenceConfig()));
        return THIS();
    }
1229892
public static int countGC(Sequence<NucleotideCompound> sequence) {
		CompoundSet<NucleotideCompound> cs = sequence.getCompoundSet();
		NucleotideCompound G = cs.getCompoundForString("G");
		NucleotideCompound C = cs.getCompoundForString("C");
		NucleotideCompound g = cs.getCompoundForString("g");
		NucleotideCompound c = cs.getCompoundForString("c");
		return countCompounds(sequence, G, C, g, c);
	}
923381
def find_first_stop_codon(nucleotide_sequence):
    
    n_mutant_codons = len(nucleotide_sequence) // 3
    for i in range(n_mutant_codons):
        codon = nucleotide_sequence[3 * i:3 * i + 3]
        if codon in STOP_CODONS:
            return i
    return -1
242063
public static Bit2Array convertNSequenceToBit2Array(NucleotideSequence seq) {
        if (seq.containWildcards())
            throw new IllegalArgumentException("Sequences with wildcards are not supported.");
        Bit2Array bar = new Bit2Array(seq.size());
        for (int i = 0; i < seq.size(); i++)
            bar.set(i, seq.codeAt(i));
        return bar;
    }
628785
public static <S extends Sequence<C>, C extends Compound> int getGCGChecksum(S sequence) {
		String s = sequence.toString().toUpperCase();
		int count = 0, check = 0;
		for (int i = 0; i < s.length(); i++) {
			count++;
			check += count * s.charAt(i);
			if (count == 57) {
				count = 0;
			}
		}
		return check % 10000;
	}
904297
public AbstractSequence<NucleotideCompound> getSequence() throws CompoundNotFoundException {
		DNASequenceCreator creator = new DNASequenceCreator(ABITracerCompoundSet.getABITracerCompoundSet());
		return creator.getSequence(sequence, 0);
	}
886809
public static <S extends Sequence<C>, C extends Compound> String getGCGHeader(List<S> sequences) {
		StringBuilder header = new StringBuilder();
		S s1 = sequences.get(0);
		header.append(String.format("MSA from BioJava%n%n MSF: %d  Type: %s  Check: %d ..%n%n",
				s1.getLength(), getGCGType(s1.getCompoundSet()), getGCGChecksum(sequences)));
		String format = " Name: " + getIDFormat(sequences) + " Len: " + s1.getLength() + "  Check: %4d  Weight: 1.0%n";
		for (S as : sequences) {
			header.append(String.format(format, as.getAccession(), getGCGChecksum(as)));
			// TODO show weights in MSF header
		}
		header.append(String.format("%n//%n%n"));
		// TODO? convert gap characters to '.'
		return header.toString();
	}