Shared base method for defining new sequence types.
183433
function defineSequenceType(base, name, overrides) {
    /** @constructor */
    var ctor = function ctor() {};

    // Make this type inherit from the specified base.
    ctor.prototype = new base();

    // Attach overrides to the new sequence type's prototype.
    for (var override in overrides) {
      ctor.prototype[override] = overrides[override];
    }

    // Define a factory method that sets the new sequence's parent to the caller
    // and (optionally) applies any additional initialization logic.
    // Expose this as a chainable method so that we can do:
    // Lazy(...).map(...).filter(...).blah(...);
    var factory = function factory() {
      var sequence = new ctor();

      // Every sequence needs a reference to its parent in order to work.
      sequence.parent = this;

      // If a custom init function was supplied, call it now.
      if (sequence.init) {
        sequence.init.apply(sequence, arguments);
      }

      return sequence;
    };

    var methodNames = typeof name === 'string' ? [name] : name;
    for (var i = 0; i < methodNames.length; ++i) {
      base.prototype[methodNames[i]] = factory;
    }

    return ctor;
  }
1268788
public static <T> Sequence<T> wrap(Sequence<T> seq, SequenceWrapper wrapper)
  {
    Preconditions.checkNotNull(seq, "seq");
    Preconditions.checkNotNull(wrapper, "wrapper");
    return new WrappingSequence<>(seq, wrapper);
  }
194137
@Override
	public List<Sequence<AminoAcidCompound>> createSequences(
			Sequence<NucleotideCompound> originalSequence) {

		List<List<AminoAcidCompound>> workingList = new ArrayList<List<AminoAcidCompound>>();

		Iterable<SequenceView<NucleotideCompound>> iter = new WindowedSequence<NucleotideCompound>(
				originalSequence, 3);

		boolean first = true;

		// If not waiting for a start codon, start translating immediately
		boolean doTranslate = !waitForStartCodon;

		for (SequenceView<NucleotideCompound> element : iter) {
			AminoAcidCompound aminoAcid = null;

			int i = 1;
			Table.CaseInsensitiveTriplet triplet = new Table.CaseInsensitiveTriplet(
					element.getCompoundAt(i++), element.getCompoundAt(i++),
					element.getCompoundAt(i++));

			Codon target = null;

			target = quickLookup.get(triplet);

			// Check for a start
			if (!doTranslate && target.isStart()) {
				doTranslate = true;
			}

			if (doTranslate) {
				if (target != null)
					aminoAcid = target.getAminoAcid();
				if (aminoAcid == null && translateNCodons()) {
					aminoAcid = unknownAminoAcidCompound;
				} else {
					if (first && initMetOnly && target.isStart()) {
						aminoAcid = methionineAminoAcidCompound;
					}
				}

				addCompoundsToList(Arrays.asList(aminoAcid), workingList);
			}

			if (doTranslate && stopAtStopCodons && target.isStop()) {
				// Check if we need to stop, but dont stop until started!
				break;
			}

			first = false;
		}
		postProcessCompoundLists(workingList);

		return workingListToSequences(workingList);
	}
875407
def createRandomSequences(self,
                          numSequences,
                          sequenceLength):
    
    for _ in xrange(numSequences):
      self.addObject(
        [numpy.random.randint(0, self.numFeatures)
                                            for _ in xrange(sequenceLength)]
      )
14829
private Map<String, Set<SequenceEntityReference>> organismToProteinRefsMap(Set<SequenceEntityReference> seqErs)
	{
		Map<String,Set<SequenceEntityReference>> map = new HashMap<String, Set<SequenceEntityReference>>();

		if(seqErs.isEmpty())
			throw new IllegalArgumentException("Empty set");
		
		if (crossSpeciesCheckEnabled) {
			for (SequenceEntityReference r : seqErs) {
				String key = getOrganismKey(r.getOrganism()); // null org. is ok (key == "")
				//collect PRs only from allowed organisms
				if(allowedOrganisms==null || allowedOrganisms.isEmpty() || allowedOrganisms.contains(key)) {
					Set<SequenceEntityReference> sers = map.get(key);
					if (sers == null) {
						sers = new HashSet<SequenceEntityReference>();
						map.put(key, sers);
					}
					sers.add(r);
				}
			}
		} else {
			final Set<SequenceEntityReference> sers = new HashSet<SequenceEntityReference>();
			for (SequenceEntityReference r : seqErs) {
				String key = getOrganismKey(r.getOrganism());
				//collect PRs only from allowed organisms
				if(allowedOrganisms==null || allowedOrganisms.isEmpty() || allowedOrganisms.contains(key)) {
					sers.add(r);
				}
			}
			map.put("", sers);
		}
				
		return map;
	}
45991
private void writeMutations(ByteBuffer key, List<Mutation> mutations) throws IOException
    {
        try
        {
            writer.write(key, mutations);
        }
        catch (InterruptedException e)
        {
            throw new IOException(e);
        }
    }
394493
def sequence_type(seq):
    '''

    '''
    if isinstance(seq, coral.DNA):
        material = 'dna'
    elif isinstance(seq, coral.RNA):
        material = 'rna'
    elif isinstance(seq, coral.Peptide):
        material = 'peptide'
    else:
        raise ValueError('Input was not a recognized coral.sequence object.')
    return material
165069
def from_sequence(cls, seq, order=None, **kwargs):
        """"""
        for arg in seq:
            yield cls(arg, order=order, **kwargs)
226894
def extend(self, elem_seq):
    """"""

    if elem_seq is None:
      return
    try:
      elem_seq_iter = iter(elem_seq)
    except TypeError:
      if not elem_seq:
        # silently ignore falsy inputs :-/.
        # TODO(ptucker): Deprecate this behavior. b/18413862
        return
      raise

    new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
    if new_values:
      self._values.extend(new_values)
    self._message_listener.Modified()
1270622
def set_type(self, sequence_type):
        ''''''
        if not(self.sequence_type):
            for id, r in self.sequence.iteritems():
                assert(r.residue_type == None)
                r.residue_type = sequence_type
            self.sequence_type = sequence_type
884436
private void addSequences(Iterable<Sequence> sequences) {
		Transaction tx = null;
		try {
			tx = neo4jDb.beginTx();
			for ( Sequence sequence : sequences ) {
				addSequence( sequence );
			}
			tx.success();
		}
		finally {
			tx.close();
		}
	}
751410
public List<Statement> createSequencesStatements(Iterable<Sequence> sequences) {
		List<Statement> statements = new ArrayList<Statement>();
		for ( Sequence sequence : sequences ) {
			addSequence( statements, sequence );
		}
		return statements;
	}
1038853
public DictionaryBuilder add(CharSequence seq) throws DictionaryBuilderException {
        if (d_finalized)
            throw new DictionaryBuilderException("Cannot add a sequence to a finalized DictionaryBuilder.");

        if (d_prevSeq != null && compareCharacterSequences(d_prevSeq, seq) >= 0)
            throw new DictionaryBuilderException(String.format("Sequences are not added in lexicographic order: %s %s", d_prevSeq, seq));

        d_prevSeq = seq;

        // Traverse across the shared prefix.
        int i = 0;
        State curState = d_startState;
        for (int len = seq.length(); i < len; i++) {
            State nextState = curState.move(seq.charAt(i));
            if (nextState != null)
                curState = nextState;
            else
                break;
        }

        if (curState.hasOutgoing())
            replaceOrRegisterIterative(curState);

        addSuffix(curState, seq.subSequence(i, seq.length()));

        ++d_nSeqs;

        return this;
    }
1276568
void expectGeneratorSupertype(Node n, JSType type, String msg) {
    if (!getNativeType(GENERATOR_TYPE).isSubtypeOf(type)) {
      mismatch(n, msg, type, GENERATOR_TYPE);
    }
  }
1100412
public static void generateMutations(long seq, TxLog txLog, Consumer<Mutation> consumer) {
    Map<Bytes, Mutation> mutationMap = new HashMap<>();
    for (LogEntry le : txLog.getLogEntries()) {
      LogEntry.Operation op = le.getOp();
      Column col = le.getColumn();
      byte[] cf = col.getFamily().toArray();
      byte[] cq = col.getQualifier().toArray();
      byte[] cv = col.getVisibility().toArray();
      if (op.equals(LogEntry.Operation.DELETE) || op.equals(LogEntry.Operation.SET)) {
        Mutation m = mutationMap.computeIfAbsent(le.getRow(), k -> new Mutation(k.toArray()));
        if (op.equals(LogEntry.Operation.DELETE)) {
          if (col.isVisibilitySet()) {
            m.putDelete(cf, cq, new ColumnVisibility(cv), seq);
          } else {
            m.putDelete(cf, cq, seq);
          }
        } else {
          if (col.isVisibilitySet()) {
            m.put(cf, cq, new ColumnVisibility(cv), seq, le.getValue().toArray());
          } else {
            m.put(cf, cq, seq, le.getValue().toArray());
          }
        }
      }
    }
    mutationMap.values().forEach(consumer);
  }
413193
public static <A, B, T> Parser<T> sequence(
      final Parser<A> p1, final Parser<B> p2, final BiFunction<? super A, ? super B, ? extends T> map) {
    return new Parser<T>() {
      @Override boolean apply(ParseContext ctxt) {
        boolean r1 = p1.apply(ctxt);
        if (!r1) return false;
        A o1 = p1.getReturn(ctxt);
        boolean r2 = p2.apply(ctxt);
        if (!r2) return false;
        B o2 = p2.getReturn(ctxt);
        ctxt.result = map.apply(o1, o2);
        return true;
      }
      @Override public String toString() {
        return map.toString();
      }
    };
  }
872806
public static <T> Parser<T> sequence(
      Parser<?> p1, Parser<?> p2, Parser<?> p3, Parser<?> p4, Parser<T> p5) {
    return sequence(p1, p2, p3, p4, p5,
        InternalFunctors.<Object, Object, Object, Object, T>lastOfFive());
  }