Version to use for seq2seq.
762304
def attention_lm_moe_translation():
  """"""
  hparams = attention_lm_moe_base()
  hparams.layer_preprocess_sequence = "n"
  hparams.layer_postprocess_sequence = "da"
  hparams.learning_rate = 0.4
  hparams.prepend_mode = "prepend_inputs_masked_attention"
  hparams.max_length = 512
  hparams.label_smoothing = 0.1
  hparams.layer_prepostprocess_dropout = 0.2
  hparams.num_hidden_layers = 6
  hparams.moe_layers = "0,1,2,3,4,5"
  hparams.shared_embedding_and_softmax_weights = True
  return hparams
175037
def make_sequence(seq, name="S"):
    
    return ["{}_{}_{}".format(name, i, x) for i, x in enumerate(seq)]
15323
def _jseq(self, cols, converter=None):
        """"""
        return _to_seq(self.sql_ctx._sc, cols, converter)
229585
def filter_seq(seq):
     ''''''
     if seq.res:
          return None
     n = nt.Factors(seq.factors)
     guide, s, t = aq.canonical_form(n)
     seq.guide = guide
     # The target_tau for the composite is at most the class minus extant prime factor count
     cls = aq.get_class(guide=guide)
     num_larges = seq.factors.count('P')
     upper_bound_tau = cls - num_larges - len(t)

     if cls < 2 or upper_bound_tau < 2: # Cheap tests to eliminate almost all sequences
          return None

     # Next we ignore sequences whose guide is solely a power of 2 greater than 3
     v = nt.Factors({p: a for p, a in guide.items() if p != 2 and a > 0})
     if int(v) == 1 and cls > 3:
          return None
     # This condition greatly reduces fdb load, but excludes a lot of sequences
     if not aq.is_driver(guide=guide):
          return None

     return n, guide
719715
function compareVersions(v1, v2) {
    if (semver.gt(v1.tag, v2.tag)) {
        return -1;
    }
    if (semver.lt(v1.tag, v2.tag)) {
        return 1;
    }
    return 0;
}
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
852559
def highlightSubsequence(sequence, x1, x2, start=' [', stop = '] ') :
	"""'"""

	seq = list(sequence)
	print x1, x2-1, len(seq)
	seq[x1] = start + seq[x1]
	seq[x2-1] = seq[x2-1] + stop
	return ''.join(seq)
387776
private boolean containsSeq(String seq) {
        int state = 0;
        for (int i = 0; i < seq.length(); i++) {
            state = next(state, seq.charAt(i));

            if (state == -1)
                return false;
        }

        return d_finalStates.get(state);
    }
453510
function SEQ() {
        var parsers = [];
        for (var _i = 0; _i < (arguments.length - 0); _i++) {
            parsers[_i] = arguments[_i + 0];
        }
        var _func = 'SEQ';
        var _parsers = [];

        for (var i = 0; i < parsers.length; ++i) {
            _parsers.push(_wrap(parsers[i]));
        }

        return function (buffer, index, depth) {
            if (typeof depth === "undefined") { depth = 0; }
            _trace(_func, depth, true);
            var idx = index;
            var children = [];

            for (var i = 0; i < _parsers.length; ++i) {
                var r = _parsers[i](buffer, idx, depth + 1);

                children.push(r);

                if (paka.S.OK == r.status) {
                    idx += r.length;
                } else {
                    r = R.error(paka.P.SEQ, idx, children, r.err);
                    _update_last_error(r);
                    _trace(_func, depth, false, paka.S.ERROR);
                    return r;
                }
            }

            _trace(_func, depth, false, paka.S.OK);
            return R.ok(paka.P.SEQ, index, idx - index, children);
        };
    }
115905
def _get_seq2c_options(data):
    
    cov2lr_possible_opts = ["-F"]
    defaults = {}
    ropts = config_utils.get_resources("seq2c", data["config"]).get("options", [])
    assert len(ropts) % 2 == 0, "Expect even number of options for seq2c" % ropts
    defaults.update(dict(tz.partition(2, ropts)))
    cov2lr_out, lr2gene_out = [], []
    for k, v in defaults.items():
        if k in cov2lr_possible_opts:
            cov2lr_out += [str(k), str(v)]
        else:
            lr2gene_out += [str(k), str(v)]
    return cov2lr_out, lr2gene_out
240797
def _get_qkeysequence(shortcut):
    """"""
    if shortcut is None:
        return []
    if isinstance(shortcut, (tuple, list)):
        return [_get_qkeysequence(s) for s in shortcut]
    assert isinstance(shortcut, string_types)
    if hasattr(QKeySequence, shortcut):
        return QKeySequence(getattr(QKeySequence, shortcut))
    sequence = QKeySequence.fromString(shortcut)
    assert not sequence.isEmpty()
    return sequence
756761
def get_seqs_fasta(seqs, names, out_fa):
    """"""
    with open(out_fa, 'w') as fa_handle:
        for s, n in itertools.izip(seqs, names):
            print(">cx{1}-{0}\n{0}".format(s, n), file=fa_handle)
    return out_fa
100763
def libseq_parse(self, line):
        """"""
        count = line.count(',')
        if count > 1:
            raise ValueError("""ERROR: There are too many commas in your
            lib_seq line. There should only be one, between the two filepath
            globs.""")
        if count == 0:
            raise ValueError("""ERROR: There are no commas in your
            lib_seq line. There should be one, between the two filepath
            globs.""")
        line = [x.strip() for x in line.split() if x]
        #print(line)

        #This block tries to fix user input if there is an inappropriate
        # number of commas or spaces associated with commas
        if len(line) > 13:
            commas = [x for x in line if "," in x]
            if commas:
                #this handles the case if there was an extra space added on
                # both sides of the comma
                if (len(commas) == 1) and (commas[0] != ','):
                    if (commas[0][-1] == ',') or (commas[0][0] == ','):
                        line = [line[0]] + ["".join(line[1:3])] + line[3:]
                #This handles the case where there is an extra space on either
                #side of the comma
                elif line[2] == ',':
                    line = [line[0]] + ["".join(line[1:4])] + line[4::]

        #make sure there is an appropriate numer of elements in list
        if (len(line) ) != 13:
            raise ValueError("""ERROR: There are {0} values in the lib_seq line when
                             there should be 12. Check your input meraculous
                             config file for errors and make sure that it matches
                             the specification for the Meraculous manual.""".format(
                                 len(line)))

        for index in self.indices:
            if index == 1:
                globs = [os.path.abspath(x.strip()) for x in line[1].split(',') if x]
                #make sure there are only two filepaths to search for globs
                if len(globs) != 2:
                    raise ValueError("""ERROR: remember to split your glob
                    filepaths in lib_seq with a comma. This error occured because
                    the program was looking for two glob filepaths, but instead
                    found {}: {}""".format(len(globs), globs))
                self.data["globs"] = globs
                #Note that glob.glob returns an empty list if the file or glob
                # filepath does not exist.
                forwards = glob.glob(os.path.abspath(globs[0]))
                reverses = glob.glob(os.path.abspath(globs[1]))
                # print(os.path.abspath(globs[0]))
                # print("globs: ", globs)
                # print("forwards: ", forwards)
                # print("reverses: ", reverses)
                #At this point the
                if (len(forwards) < 1) or (len(reverses) < 1):
                    # print("forwards: ", forwards)
                    # print("reverses: ", reverses)

                    report = []
                    if len(forwards) < 1:
                        report.append(globs[0])
                    if len(reverses) < 1:
                        report.append(globs[1])
                    raise ValueError("""ERROR: no read files were found for the glob strings,
                    {}.

                    Please check the glob string and/or use absolute
                    file paths. A common source of this error is using
                    relative filepaths from the incorrect directory, or
                    referring to files that do not exist.""".format(report))
                if len(forwards) != len(reverses):
                    raise ValueError("""ERROR: the number of reverse read files does not
                    match the number of forward read files""")
                #zip the pairs together into tuples, not lists
                self.data["pairs"] = [x for x in zip(sorted(forwards), sorted(reverses))]

            self.data[self.indices.get(index)] = line[index]
884731
def find_seq_rec(block, name, case_sensitive=True):
    """"""
    if case_sensitive:
        def test(name, rec):
            return name in rec['id']
    else:
        def test(name, rec):
            return name.upper() in rec['id'].upper()

    for rec in block['sequences']:
        if test(name, rec):
            return rec
    raise ValueError("No sequence ID matches %s" % repr(name))
1157971
def __registerSeqStr():
    """"""
    _SeqStr = lambda self: (self and "[%s]" % (", ".join(map(repr, self)))) or "[]"
    _SeqRepr = lambda self: (self and "[%s]" % (", ".join(map(repr, self)))) or "[]"

    seqs = (StdStringVector, StdLongVector, CommandInfoList,
            AttributeInfoList, AttributeInfoListEx, PipeInfoList,
            DeviceDataHistoryList,
            GroupReplyList, GroupAttrReplyList, GroupCmdReplyList,
            DbData, DbDevInfos, DbDevExportInfos, DbDevImportInfos, DbHistoryList)

    for seq in seqs:
        seq.__str__ = _SeqStr
        seq.__repr__ = _SeqRepr
384834
def dna_to_re(seq):
    

    seq = seq.replace('K', '[GT]')
    seq = seq.replace('M', '[AC]')
    seq = seq.replace('R', '[AG]')
    seq = seq.replace('Y', '[CT]')
    seq = seq.replace('S', '[CG]')
    seq = seq.replace('W', '[AT]')
    seq = seq.replace('B', '[CGT]')
    seq = seq.replace('V', '[ACG]')
    seq = seq.replace('H', '[ACT]')
    seq = seq.replace('D', '[AGT]')
    seq = seq.replace('X', '[GATC]')
    seq = seq.replace('N', '[GATC]')

    return re.compile(seq)
456724
def seq(self):
        """"""

        if self.sequence_file:
            log.debug('{}: reading sequence from sequence file {}'.format(self.id, self.sequence_path))
            tmp_sr = SeqIO.read(self.sequence_path, 'fasta')
            return tmp_sr.seq

        elif self.metadata_file:
            log.debug('{}: reading sequence from metadata file {}'.format(self.id, self.metadata_path))
            tmp_sr = SeqIO.read(self.metadata_path, 'uniprot-xml')
            return tmp_sr.seq

        else:
            if not self._seq:
                log.debug('{}: no sequence stored in memory'.format(self.id))
            else:
                log.debug('{}: reading sequence from memory'.format(self.id))

            return self._seq