Verifies that all entries in the Collection satisfy the predicate. If any do not, throw an
IllegalArgumentException with the specified message for the first invalid entry.
162824
@VisibleForTesting
  protected static <T> List<T> validateArgument(List<T> list, Predicate<T> predicate,
                                                Function<T, String> msgFn) {

    final Optional<T> firstInvalid = list.stream()
        .filter(predicate.negate())
        .findAny();

    if (firstInvalid.isPresent()) {
      throw new IllegalArgumentException(firstInvalid.map(msgFn).get());
    }
    return list;
  }
77588
public ValidationResult check(Entry entry)
	{
		result = new ValidationResult();

		if (entry.isDelete())
		{
			reportMessage(Severity.FIX, entry.getOrigin(), FIX_ID, entry.getPrimaryAccession());
		}
		return result;
	}
854646
@CheckReturnValue
  public ScannerSupplier filter(Predicate<? super BugCheckerInfo> predicate) {
    ImmutableSet.Builder<String> disabled = ImmutableSet.builder();
    for (BugCheckerInfo check : getAllChecks().values()) {
      if (!predicate.apply(check)) {
        disabled.add(check.canonicalName());
      }
    }
    return new ScannerSupplierImpl(getAllChecks(), severities(), disabled.build(), getFlags());
  }
1097335
public static <T, P, R extends Collection<T>> R rejectWith(
            Iterable<T> iterable,
            Predicate2<? super T, ? super P> predicate,
            P parameter,
            R targetCollection)
    {
        if (iterable instanceof RichIterable)
        {
            return ((RichIterable<T>) iterable).rejectWith(predicate, parameter, targetCollection);
        }
        if (iterable instanceof ArrayList)
        {
            return ArrayListIterate.rejectWith(
                    (ArrayList<T>) iterable,
                    predicate,
                    parameter,
                    targetCollection);
        }
        if (iterable instanceof RandomAccess)
        {
            return RandomAccessListIterate.rejectWith((List<T>) iterable, predicate, parameter, targetCollection);
        }
        if (iterable != null)
        {
            return IterableIterate.rejectWith(iterable, predicate, parameter, targetCollection);
        }
        throw new IllegalArgumentException("Cannot perform a rejectWith on null");
    }
923024
public static <K, V> Predicate<Map<K, V>> anyEntry(
      Predicate<? super Map.Entry<K, V>> p) {
    return forEntries(Predicates.<Map.Entry<K, V>>any(p));
  }
183340
@Override
    public boolean contains(final ENTRY entry) throws CouldNotPerformException {
        if (entry == null) {
            throw new NotAvailableException("entry");
        }
        return contains(entry.getId());
    }
306029
public void hasFirstEntry(@NullableDecl Object key, @NullableDecl Object value) {
    Entry<Object, Object> expectedEntry = Maps.immutableEntry(key, value);
    if (actualAsNavigableMap().isEmpty()) {
      failWithActual("expected to have first entry", expectedEntry);
      return;
    }

    Entry<?, ?> actualFirstEntry = actualAsNavigableMap().firstEntry();
    if (!Objects.equal(actualFirstEntry, expectedEntry)) {
      Object actualFirstKey = actualFirstEntry.getKey();
      if (actualAsNavigableMap().entrySet().contains(expectedEntry)) {
        failWithoutActual(
            simpleFact(
                lenientFormat(
                    "Not true that %s has first entry <%s>. "
                        + "It does contain this entry, but the first entry is <%s>",
                    actualAsString(), expectedEntry, actualFirstEntry)));
      } else if (Objects.equal(actualFirstKey, key)) {
        failWithoutActual(
            simpleFact(
                lenientFormat(
                    "Not true that %s has first entry <%s>, the first value is <%s>",
                    actualAsString(), expectedEntry, actualFirstEntry.getValue())));
      } else if (Objects.equal(actualFirstEntry.getValue(), value)) {
        failWithoutActual(
            simpleFact(
                lenientFormat(
                    "Not true that %s has first entry <%s>, the first key is <%s>",
                    actualAsString(), expectedEntry, actualFirstKey)));
      } else if (actualAsNavigableMap().containsKey(key)) {
        failWithoutActual(
            simpleFact(
                lenientFormat(
                    "Not true that %s has first entry <%s>. It does contain this key, "
                        + "but the key is mapped to <%s>, and the first entry is <%s>",
                    actualAsString(),
                    expectedEntry,
                    actualAsNavigableMap().get(key),
                    actualFirstEntry)));
      } else if (actualAsNavigableMap().containsValue(value)) {
        Set<Object> keys = new LinkedHashSet<>();
        for (Entry<?, ?> actualEntry : actualAsNavigableMap().entrySet()) {
          if (Objects.equal(actualEntry.getValue(), value)) {
            keys.add(actualEntry.getKey());
          }
        }
        failWithoutActual(
            simpleFact(
                lenientFormat(
                    "Not true that %s has first entry <%s>. It does contain this value, but the "
                        + "value is mapped from the keys <%s>, and the first entry is <%s>",
                    actualAsString(), expectedEntry, keys, actualFirstEntry)));
      } else {
        failWithoutActual(
            simpleFact(
                lenientFormat(
                    "Not true that %s has first entry <%s>. "
                        + "It does not contain this entry, and the first entry is <%s>",
                    actualAsString(), expectedEntry, actualFirstEntry)));
      }
    }
  }
244933
public static <T> List<T> filter( Iterable<T> collection, Predicate<T> predicate)
    {
        List<T> filtered = new ArrayList<T>();
        for (T element : collection)
        {
        	if (predicate.isVerifiedBy(element))
        	{
        		filtered.add(element);
        	}
        }
        return filtered;
    }
963892
public <E extends Exception> boolean allMatch(Try.IntPredicate<E> filter) throws E {
        return allMatch(0, size(), filter);
    }
719362
public ValidationResult check(Entry entry) {
        result = new ValidationResult();
        
        if (entry == null) {
            return result;
        }

        String dataClass = entry.getDataClass();
        if (dataClass != null && dataClass.equals(Entry.PRT_DATACLASS)) {
            return result;
        }
        //collect all gap features
        Collection<Feature> gapFeatures =
                SequenceEntryUtils.getFeatures(Feature.GAP_FEATURE_NAME, entry);
        Collection<Feature> assembly_gapFeatures =
            SequenceEntryUtils.getFeatures(Feature.ASSEMBLY_GAP_FEATURE_NAME, entry);
        gapFeatures.addAll(assembly_gapFeatures); //assembly_gaps and gaps are mutually exclusive,there is other check to complain
        if (entry.getSequence() == null || entry.getSequence().getSequenceByte() == null) {
            return result;
        }

        int baseCount=0;
        List<NRegion> nRegions = new ArrayList<NRegion>();
        boolean lastBaseN = false;
        int matchStart = 0;
        int matchEnd = 0;
        byte[] sequenceByte=entry.getSequence().getSequenceByte();
        for(byte base:sequenceByte)
        {
        	
        	if('n'==(char)base)
        	{
        		if (!lastBaseN) 
        		{
                    matchStart = baseCount + 1;//as arrays are from 0 and sequence starts from 1
                    lastBaseN = true;
                }
        		
        	}
        	else 
        	{
                if (lastBaseN) 
                {
                    matchEnd = baseCount;
                    lastBaseN = false;
//                    System.out.println("matchStart = " + matchStart);
//                    System.out.println("matchEnd = " + matchEnd);
//                  System.out.println("matchedString = " + matchedString);
                    NRegion regionMatch = new NRegion(matchStart, matchEnd);
                    nRegions.add(regionMatch);
                }
        	
            }
        	baseCount++;
        }
    
        for (NRegion nRegion : nRegions) {
        	 
         	
         	boolean matchedRegion = false;
        	//whether we have found a gap feature that corresponds to this nRegion
            for (Feature gapFeature : gapFeatures) {
            	CompoundLocation<Location> compoundLocation = gapFeature.getLocations();
                if (compoundLocation == null || compoundLocation.getLocations() == null ||
                        compoundLocation.getLocations().size() != 1) {
                    //if there is more than 1 location, just bail, there are other checks to complain if the location is
                    //not a single location
                    break;
                }

                Location location = compoundLocation.getLocations().get(0);
                Long featureStart = location.getBeginPosition();
                Long featureEnd = location.getEndPosition();

                if (nRegion.getStart() == featureStart && nRegion.getEnd() == featureEnd) {
                    matchedRegion = true;
                    break;
                }
            }

              if (!matchedRegion) {
                  processMissingGapFeature(entry, nRegion);
              }
          
        }
        
      
        finish(entry);

        return result;
    }
482837
private static <E> void validateCounter(Counter<E> counts) {
    for (Map.Entry<E, Double> entry : counts.entrySet()) {
      E item = entry.getKey();
      Double dblCount = entry.getValue();
      if (dblCount == null) {
        throw new IllegalArgumentException("ERROR: null count for item " + item + "!");
      }
      if (dblCount < 0) {
        throw new IllegalArgumentException("ERROR: negative count " + dblCount + " for item " + item + "!");
      }
    }
  }
717446
public static <E> boolean all(final Iterable<E> iterable, final Predicate<E> pred) {
        return every(iterable, pred);
    }
642817
public static boolean contains(final Map<?, ?> map, final Map.Entry<?, ?> entry) {
        return contains(map, entry.getKey(), entry.getValue());
    }
247231
public final boolean contains(E entry) {
        TreeEntry<E> e = getEntry(entry);
        return e != null;
    }
351114
public static boolean verify(byte[] text, byte[] signatureValue, PublicKey key, String algorithm)
        throws SignatureException {
        Signature signature;
        try {
            signature = Signature.getInstance(algorithm);
            signature.initVerify(key);
        } catch (GeneralSecurityException e) {
            throw new IllegalArgumentException("cannot initialize signature for algorithm " + algorithm, e);
        }
        signature.update(text);
        return signature.verify(signatureValue);
    }
492281
protected void validateArgumentList(String[] args, boolean supportsTarget, boolean supportsDefaultTarget) {
        checkRequiredArguments(args, !supportsTarget || supportsDefaultTarget);

        // If the command supports a target name
        // skip the first argument if it is the target name.
        int firstArg = 1;
        if (supportsTarget) {
            if (!supportsDefaultTarget) {
                firstArg = 2;
            } else {
                if (args.length > 1) {
                    String primArg = args[1];
                    if (!primArg.startsWith("-"))
                        firstArg = 2;
                }
            }
        }

        // Arguments and values come in pairs (expect -password).
        // Anything outside of that pattern is invalid.
        // Loop through, jumping in pairs except when we encounter
        // -password -- that may be an interactive prompt which won't
        // define a value.
        for (int i = firstArg; i < args.length; i++) {
            String argName = getArgName(args[i]);
            if (!isKnownArgument(argName)) {
                throw new IllegalArgumentException(getMessage("invalidArg", argName));
            }
            // Everything we accept as an arg expects an name=value pair.
            // If we see anything without the =value pair, error
            if (!args[i].contains("=")) {
                throw new IllegalArgumentException(getMessage("missingValue", argName));
            }
        }
    }
1051646
public <E extends Exception> boolean allMatch(Try.BooleanPredicate<E> filter) throws E {
        return allMatch(0, size(), filter);
    }