Reverse complement a nucleotide sequence.

        @return: The reverse complemented sequence as an instance of the
            current class.
763663
def reverseComplement(self):
        
        quality = None if self.quality is None else self.quality[::-1]
        sequence = self.sequence.translate(self.COMPLEMENT_TABLE)[::-1]
        return self.__class__(self.id, sequence, quality)
413270
def conjugate(self):
        """"""
        return self.__class__.create(
            *[arg.conjugate() for arg in reversed(self.args)])
119231
def make_codon_list(protein_seq, template_dna=None, include_stop=True):
    

    codon_list = []

    if template_dna is None:
        template_dna = []

    # Reverse translate each codon, preferring (in order):
    # 1. The codon with the most similarity to the template codon.
    # 2. The codon with the highest natural usage.

    for i, res in enumerate(protein_seq.upper()):
        try: template_codon = template_dna[3*i:3*i+3]
        except IndexError: template_codon = '---'

        # Already sorted by natural codon usage
        possible_codons = dna.ecoli_reverse_translate[res]

        # Sort by similarity.  Note that this is a stable sort.
        possible_codons.sort(
                key=lambda x: dna.num_mutations(x, template_codon))

        # Pick the best codon.
        codon_list.append(possible_codons[0])

    # Make sure the sequence ends with a stop codon.
    last_codon = codon_list[-1]
    stop_codons = dna.ecoli_reverse_translate['.']

    if include_stop and last_codon not in stop_codons:
        codon_list.append(stop_codons[0])

    return codon_list
977658
def reverse_sequences(records):
    
    logging.info('Applying _reverse_sequences generator: '
                 'reversing the order of sites in sequences.')
    for record in records:
        rev_record = SeqRecord(record.seq[::-1], id=record.id,
                               name=record.name,
                               description=record.description)
        # Copy the annotations over
        _reverse_annotations(record, rev_record)

        yield rev_record
975465
def variant_matches_reference_sequence(variant, ref_seq_on_transcript, strand):
    
    if strand == "-":
        ref_seq_on_transcript = reverse_complement_dna(ref_seq_on_transcript)
    return ref_seq_on_transcript == variant.ref
1371184
def _guess_sequence_type_from_string(self, seq):
        ''''''
        # Define expected residues for each sequence type
        aa_chars = ['P','V','L','I','M','F','Y','W','H','K','R','Q','N','E','D','S','X','*']
        aas = set(itertools.chain(aa_chars, [lower(a) for a in aa_chars]))
        na_chars = ['A', 'T', 'G', 'C', 'N', 'U']
        nas = set(itertools.chain(na_chars, [lower(a) for a in na_chars]))

        num_nucleotide = 0
        num_protein = 0
        count = 0
        for residue in seq:
            if residue in nas:
                num_nucleotide += 1
            elif residue in aas:
                num_protein += 1
            else:
                raise Exception('Encountered unexpected character when attempting to guess sequence type: %s' % (residue))
            count += 1
            if count >300: break
        if float(num_protein) / (num_protein+num_nucleotide) > 0.1:
            return self.PROTEIN_SEQUENCE_TYPE
        else:
            return self.NUCLEOTIDE_SEQUENCE_TYPE
114348
public static int getCDSLengthReverse(List<Integer> exonStarts, List<Integer> exonEnds, int cdsStart, int cdsEnd) {

		int codingLength = 0;

		if (cdsEnd < cdsStart) {
			int tmp = cdsEnd;
			cdsEnd = cdsStart;
			cdsStart = tmp;
		}
		cdsStart = cdsStart + base;

		// map reverse
		for (int i = exonStarts.size() - 1; i >= 0; i--) {

			int end = exonStarts.get(i);
			int start = exonEnds.get(i);

			if (end < start) {
				int tmp = end;
				end = start;
				start = tmp;
			}
			start = start + base;

			if ((start < cdsStart && end < cdsStart) || (start > cdsEnd && end > cdsEnd))
				continue;

			if (start < cdsStart)
				start = cdsStart;

			if (end > cdsEnd)
				end = cdsEnd;

			codingLength += (end - start + 1);
		}
		return codingLength - 3;
	}
646201
def reverse_reference(self):
        ''''''
        self.ref_start = self.ref_length - self.ref_start - 1
        self.ref_end = self.ref_length - self.ref_end - 1
343362
@SuppressWarnings("unchecked")
	protected <C extends Compound> Sequence<C> reverseSequence(Sequence<C> sequence) {
		if(getStrand() != Strand.NEGATIVE) {
			return sequence;
		}

		Sequence<C> reversed = new ReversedSequenceView<C>(sequence);
		// "safe" operation as we have tried to check this
		if(canComplement(sequence)) {
			Sequence<ComplementCompound> casted = (Sequence<ComplementCompound>) reversed;
			ComplementSequenceView<ComplementCompound> complement =
					new ComplementSequenceView<ComplementCompound>(casted);
			return (Sequence<C>)complement;
		}
		return reversed;
	}
1168829
def complete(self):
        
        return (
            self.contains_start_codon and
            self.contains_stop_codon and
            self.coding_sequence is not None and
            len(self.coding_sequence) % 3 == 0
        )
1032628
private List<SequenceState<S, O, D>> retrieveMostLikelySequence() {
        // Otherwise an HMM break would have occurred and message would be null.
        assert !message.isEmpty();

        final S lastState = mostLikelyState();

        // Retrieve most likely state sequence in reverse order
        final List<SequenceState<S, O, D>> result = new ArrayList<>();
        ExtendedState<S, O, D> es = lastExtendedStates.get(lastState);
        while(es != null) {
            final SequenceState<S, O, D> ss = new SequenceState<>(es.state, es.observation,
                    es.transitionDescriptor);
            result.add(ss);
            es = es.backPointer;
        }

        Collections.reverse(result);
        return result;
    }
985470
def reverse_complement(self):
        '''
        
        '''
        if self._reverse_complement is None:
            self._reverse_complement = self._get_reverse_complement()
        return self._reverse_complement
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);
	}
114409
public T reverse() {
        String id = getId();
        String REVERSE = "_REVERSE";
        if (id.endsWith(REVERSE)) {
            setId(id.substring(0, id.length() - REVERSE.length()));
        }

        float start = mStart;
        float end = mEnd;
        mStart = end;
        mEnd = start;
        mReverse = !mReverse;
        return self();
    }
733624
def inverse(self):
        
        result = G1Element()
        librelic.g1_neg_abi(byref(result), byref(self))
        return result
119237
public function toASN1(): Sequence
    {
        $elements = array(new Integer($this->_version), $this->_algo->toASN1(),
            new OctetString($this->_privateKeyData));
        // @todo decode attributes and public key
        return new Sequence(...$elements);
    }
64790
public String sequence() {
    return dN == asg.length() ? null : substr(asg, dN + 1, asg.length());
  }