Raise a ValueError if the given sequence doesn't pass all of the Gen9 
    quality control design guidelines.  Certain checks can be enabled or 
    disabled via the command line.
175772
def apply_quality_control_checks(
        seq,
        check_gen9_seqs=True,
        check_short_length=True,
        check_local_gc_content=True,
        check_global_gc_content=True):
    

    seq = seq.upper()
    failure_reasons = []
    
    # Minimum length
    if check_short_length:
        if len(seq) < min_gene_length:
            failure_reasons.append('minimum_length: Sequence is %d bp long and needs to be at least %d bp'%(len(seq),min_gene_length))

    # Maximum length
    if len(seq) > max_gene_length:
        failure_reasons.append('maximum_length: Sequence is %d bp long and needs to be shorter than %d bp'%(len(seq),max_gene_length))

    # Gen9 restricted sequences
    if check_gen9_seqs:
        for site in reserved_restriction_sites:
            pattern = dna.dna_to_re(site)
            reverse_site = dna.reverse_complement(site)
            reverse_pattern = dna.dna_to_re(reverse_site)

            if pattern.match(seq):
                failure_reasons.append('gen9_restricted_sequences: Reserved sequence %s is present'%(site))
            if reverse_pattern.match(seq):
                failure_reasons.append('gen9_restricted_sequences: Reverse-complement of reserved sequence %s is present'%(site))

    # Global GC content
    if check_global_gc_content:
        gc_content = dna.gc_content(seq)

        if gc_content < global_gc_content_min:
            failure_reasons.append('global_gc_content_min: Global GC content is %.3f%% and must be at least %.3f%%'%(gc_content,global_gc_content_min))

        if gc_content > global_gc_content_max:
            failure_reasons.append('global_gc_content_max: Global GC content is %.3f%% and must be less than %.3f%%'%(gc_content,global_gc_content_max))

    # Local GC content (windows)
    if check_local_gc_content:
        windows = [seq]

        if local_gc_window_size < len(seq):
            windows = dna.sliding_window(seq, local_gc_window_size)

        for seq_window in windows:
            lgc_content = dna.gc_content(seq_window)

            if lgc_content < local_gc_content_min:
                failure_reasons.append('local_gc_content_min: Local GC content is %.3f%% and must be at least %.3f%%'%(lgc_content,local_gc_content_min))
                break
            if lgc_content > local_gc_content_max:
                failure_reasons.append('local_gc_content_max: Local GC content is %.3f%% and must be less than %.3f%%'%(lgc_content,local_gc_content_max))
                break

    # Homopolymers
    for base in dna.dna_bases:
        homopolymer = base * homopolymer_max_lengths[base]
        if homopolymer in seq:
            failure_reasons.append('max_%s_homopolymer: %s'%(
                base.lower(), dna.case_highlight(seq,a_homopolymer)))

    # Make sure all the checks passed.
    if failure_reasons:
        intro = "The given sequence fails following Gen9 design guidelines:"
        raise ValueError('\n'.join([intro] + failure_reasons))
221438
def raise_potential_error!(error_code)
      return if error_code.zero? || error_code == 401 || error_code == 101

      Filemaker::Errors.raise_error_by_code(error_code)
    end
1007570
def check_allowed_letters(seq, allowed_letters_as_set):
    

    # set of unique letters in sequence
    seq_set = set(seq)

    not_allowed_letters_in_seq = [x for x in seq_set if str(x).upper() not in allowed_letters_as_set]

    if len(not_allowed_letters_in_seq) > 0:
        raise forms.ValidationError(
            "This sequence type cannot contain letters: " + ", ".join(not_allowed_letters_in_seq))
614179
def _fail(self, message, text, i):
        """"""

        raise ValueError("{}:\n{}".format(message, text[i : i + 79]))
810412
@Override
	public void validateDeps(boolean clean) {
		if (aggregator.getConfig() == null) {
			validate = true;
			return;
		}
		processDeps(true, clean, SequenceNumberProvider.incrementAndGetSequenceNumber());
	}
122638
def raise_for_invalid_annotation_value(self, line: str, position: int, key: str, value: str) -> None:
        
        if self._in_debug_mode:
            return

        if self.has_enumerated_annotation(key) and value not in self.annotation_to_term[key]:
            raise IllegalAnnotationValueWarning(self.get_line_number(), line, position, key, value)

        elif self.has_regex_annotation(key) and not self.annotation_to_pattern[key].match(value):
            raise MissingAnnotationRegexWarning(self.get_line_number(), line, position, key, value)

        elif self.has_local_annotation(key) and value not in self.annotation_to_local[key]:  # TODO condense
            raise IllegalAnnotationValueWarning(self.get_line_number(), line, position, key, value)
1122384
def _check_sig_dims(sig, read_len, n_sig, samps_per_frame):
    
    if isinstance(sig, np.ndarray):
        if sig.shape != (read_len, n_sig):
            raise ValueError('Samples were not loaded correctly')
    else:
        if len(sig) != n_sig:
            raise ValueError('Samples were not loaded correctly')
        for ch in range(n_sig):
            if len(sig[ch]) != samps_per_frame[ch] * read_len:
                raise ValueError('Samples were not loaded correctly')
305917
def raise_if_not_match(cls, action: str,
                           expected_code: Union[int, Sequence[int]],
                           reply: Reply):
        '''
        '''
        if isinstance(expected_code, int):
            expected_codes = (expected_code,)
        else:
            expected_codes = expected_code

        if reply.code not in expected_codes:
            raise FTPServerError(
                'Failed action {action}: {reply_code} {reply_text}'
                .format(action=action, reply_code=reply.code,
                        reply_text=ascii(reply.text)
                        ),
                reply.code
                )
820633
def _check_defaults(self, x_only=True):
		
		if self.x is None:
			self.err(self._check_defaults,
					 "X field is not set: please specify a parameter")
			return
		if x_only is True:
			return
		if self.y is None:
			self.err(self._check_defaults,
					 "Y field is not set: please specify a parameter")
			return
908200
def check_required(self):
        
        die = False
        for key, value in self.spec.items():
            if not getattr(self, key.upper()) and value['required']:
                print(f"{key} is a required setting. "
                      "Set via command-line params, env or file. "
                      "For examples, try '--generate' or '--help'.")
                die = True
        if die:
            sys.exit(1)
324529
function (sequenceIndex, requestType, data) {
		'use strict';
		var message = "Request #" + (sequenceIndex + 1) + " (" + requestType + ")";
		if (data.message) {
			message += ": " + data.message;
		}
		data.message = message;
		
		// the message has information that should be displayed by the test runner
		data.generatedMessage = false;
		
		data.name = "AssertionError";
		throw new AssertionError(message, data);
	}
97541
def raise_if(self, exception, message, *args, **kwargs):
        
        if issubclass(exception, self.minimum_defect):
            raise exception(*args, **kwargs)
        warn(message, SyntaxWarning, *args, **kwargs)
1052105
public void checkOrRepairSequence(final int partition, final long nextSequence, final boolean viaAntiEntropy) {
        assert nextSequence > 0;

        MetaDataContainer metaData = getMetaDataContainer(partition);
        while (true) {
            final long currentSequence = metaData.getSequence();
            if (currentSequence >= nextSequence) {
                break;
            }
            if (metaData.casSequence(currentSequence, nextSequence)) {
                final long sequenceDiff = nextSequence - currentSequence;
                if (viaAntiEntropy || sequenceDiff > 1L) {
                    // we have found at least one missing sequence between current and next sequences. if miss is detected by
                    // anti-entropy, number of missed sequences will be `miss = next - current`, otherwise it means miss is
                    // detected by observing received invalidation event sequence numbers and number of missed sequences will be
                    // `miss = next - current - 1`.
                    final long missCount = viaAntiEntropy ? sequenceDiff : sequenceDiff - 1;
                    final long totalMissCount = metaData.addAndGetMissedSequenceCount(missCount);

                    if (logger.isFinestEnabled()) {
                        logger.finest(format("%s:[map=%s,partition=%d,currentSequence=%d,nextSequence=%d,totalMissCount=%d]",
                                "Invalid sequence", name, partition, currentSequence, nextSequence, totalMissCount));
                    }
                }
                break;
            }
        }
    }
1360704
def run
      raise unless prediction.is_a?(Query)

      start  = Time.now

      number = '-?\d*\.?\d*'
      match  = @prediction.definition.match(/QI:#{number}\|(#{number})\|
                                             (#{number})\|#{number}\|
                                             #{number}\|#{number}\|#{number}\|
                                             #{number}\|#{number}/x)

      raise NotEnoughEvidence if match.nil?

      # % of splice sites confirmed by EST/mRNA-seq alignment
      splice_sites = (match[1].to_f * 100).round
      # % of exons that match an EST/mRNA-seq alignment
      exons = (match[2].to_f * 100).round

      @validation_report = MakerQIValidationOutput.new(@short_header, @header,
                                                       @description,
                                                       splice_sites, exons)
      @validation_report.run_time = Time.now - start
      @validation_report
    rescue NotEnoughEvidence
      @validation_report = ValidationReport.new('No MAKER Quality Index',
                                                :warning, @short_header,
                                                @header, @description)
    rescue StandardError
      @validation_report = ValidationReport.new('Unexpected error', :error,
                                                @short_header, @header,
                                                @description)
      @validation_report.errors.push 'Unexpected Error'
    end
970165
def _validate(self, val):
        
        if self.allow_None and val is None:
            return

        if not isinstance(val, dt_types) and not (self.allow_None and val is None):
            raise ValueError("Date '%s' only takes datetime types."%self.name)

        if self.step is not None and not isinstance(self.step, dt_types):
            raise ValueError("Step parameter can only be None or a datetime type")

        self._checkBounds(val)
785335
def check_structure_chain_quality(self, seqprop, structprop, chain_id,
                                      seq_ident_cutoff=0.5, allow_missing_on_termini=0.2,
                                      allow_mutants=True, allow_deletions=False,
                                      allow_insertions=False, allow_unresolved=True):
        """"""
        alignment = self._get_seqprop_to_structprop_alignment(seqprop=seqprop, structprop=structprop, chain_id=chain_id)

        # Compare sequence to structure's sequence using the alignment
        chain_passes_quality_check = ssbio.protein.structure.properties.quality.sequence_checker(reference_seq_aln=alignment[0],
                                                                   structure_seq_aln=alignment[1],
                                                                   seq_ident_cutoff=seq_ident_cutoff,
                                                                   allow_missing_on_termini=allow_missing_on_termini,
                                                                   allow_mutants=allow_mutants,
                                                                   allow_deletions=allow_deletions,
                                                                   allow_insertions=allow_insertions,
                                                                   allow_unresolved=allow_unresolved)
        return chain_passes_quality_check
1181725
def _raise_error(self, *args, **kwargs):
        
        log.debug("_raise_error(): %s" % kwargs)
        try:
            error_code = str(kwargs['code'])
        except KeyError as e:
            raise FaultyPayloadError('_raise_error(): %s' % kwargs)

        try:
            raise self._code_handlers[error_code]()
        except KeyError:
            raise UnknownWSSError()