Checks the coverage of sequence by source features' locations.

@param entry an entry to be checked (expected type is Entry)
@return a validation result
327557
public ValidationResult check(Entry entry) {
        result = new ValidationResult();

        if (entry == null) {
            return result;
        }

        //collect all locus features...
        Collection<Feature> locusAndGeneFeatures =
                SequenceEntryUtils.getFeaturesContainingQualifier(LOCUS_TAG_QUALIFIER_NAME, entry);

        //..then add all features containing gene qualifiers - likely to be a lot of overlap
        locusAndGeneFeatures.addAll(SequenceEntryUtils.getFeaturesContainingQualifier(GENE_QUALIFIER_NAME, entry));

        if (locusAndGeneFeatures.isEmpty()) {
            return result;
        }

        /**
         * which locus tag qualifiers are mapped to which gene_synonyms - should be a stable association
         */
        HashMap<String, List<String>> identifier2GeneSynonyms = new HashMap<String, List<String>>();

        /**
         * keep a list of locus tags that we have decided should not be considered due to unstable associations in CDS
         * features - don't even try with these ones
         */
        List<String> unreliableIdentifiers = new ArrayList<String>();

        /**
         * If there are CDS features, prioritize the list of gene_synonyms from these.
         */
        for (Feature currentFeature : locusAndGeneFeatures) {
            if (currentFeature.getName().equals(Feature.CDS_FEATURE_NAME)) {
                String identifier;
                if(!currentFeature.getQualifiers(LOCUS_TAG_QUALIFIER_NAME).isEmpty()){
                    identifier = currentFeature.getQualifiers(Qualifier.LOCUS_TAG_QUALIFIER_NAME).get(0).getValue();
                }else if (!currentFeature.getQualifiers(GENE_QUALIFIER_NAME).isEmpty()){
                    identifier = currentFeature.getQualifiers(GENE_QUALIFIER_NAME).get(0).getValue();
                }else{
                    continue;//this should not be possible as the list was built with features containing at least 1 of the above
                }

                /**
                 * look at all occurrences of any given LOCUS_TAG or GENE_QUALIFIER name - if there are mismatches
                 * between the gene_synonym qualifiers, exclude from the fix - they are unreliable and we cant decide
                 * which of the lists of syninyms we should use to overwrite the other features.
                 */
                if (!unreliableIdentifiers.contains(identifier)) {
                    if (identifier2GeneSynonyms.containsKey(identifier)) {
                        List<String> registeredSynonyms = identifier2GeneSynonyms.get(identifier);

                        List<String> newSynonymValues = new ArrayList<String>();
                        for (Qualifier synonymQualifier : currentFeature.getQualifiers(GENE_SYNONYM_NAME)) {
                            String synonymName = synonymQualifier.getValue();
                            newSynonymValues.add(synonymName);
                        }

                        /**
                         * if there are mismatches - add to the list of unreliable locus_tag/gene qualifiers...
                         */
                        if (!Arrays.deepEquals(registeredSynonyms.toArray(), newSynonymValues.toArray())) {
                            unreliableIdentifiers.add(identifier);
                            identifier2GeneSynonyms.remove(identifier);
                        }
                    } else {
                        //...otherwise set the master list
                        setMasterSynonymFeature(identifier2GeneSynonyms, identifier, currentFeature);
                    }
                }
            }
        }

        QualifierFactory qualifierFactory = new QualifierFactory();

        for (Feature currentFeature : locusAndGeneFeatures) {

            /**
             * we know this contains a locus_tag qualifier cos that's how we built the list
             */
            String identifier;
            if (!currentFeature.getQualifiers(LOCUS_TAG_QUALIFIER_NAME).isEmpty()) {
                identifier = currentFeature.getQualifiers(LOCUS_TAG_QUALIFIER_NAME).get(0).getValue();
            } else if (!currentFeature.getQualifiers(GENE_QUALIFIER_NAME).isEmpty()) {
                identifier = currentFeature.getQualifiers(GENE_QUALIFIER_NAME).get(0).getValue();
            } else {
                continue;//this should not be possible as the list was built with features containing at least 1 of the above
            }

            if (!unreliableIdentifiers.contains(identifier)) {
                if (identifier2GeneSynonyms.containsKey(identifier)) {

                    /**
                     * make a list of the gene synonyms associated with this feature...
                     */
                    List<String> currentSynonymValues = new ArrayList<String>();
                    for (Qualifier synonymQualifier : currentFeature.getQualifiers(GENE_SYNONYM_NAME)) {
                        String synonymName = synonymQualifier.getValue();
                        currentSynonymValues.add(synonymName);
                    }

                    /**
                     * ...add the synonyms where not present from the master list...
                     */
                    List<String> masterSynonyms = identifier2GeneSynonyms.get(identifier);
                    for(String registeredSynonym : masterSynonyms){
                        if(!SequenceEntryUtils.isQualifierWithValueAvailable(GENE_SYNONYM_NAME, registeredSynonym, currentFeature)){
                            currentFeature.addQualifier(qualifierFactory.createQualifier(GENE_SYNONYM_NAME, registeredSynonym));
                            reportMessage(Severity.FIX, currentFeature.getOrigin(), MESSAGE_ID_ADDED_SYNONYM, registeredSynonym, identifier);
                        }
                    }

                    /**
                     * then look at all the synonyms associated with this feature and remove those not present in the
                     * master list
                     */
                    for(String synonymValue : currentSynonymValues){
                        if(!masterSynonyms.contains(synonymValue)){
                            currentFeature.removeQualifiersWithValue(GENE_SYNONYM_NAME, synonymValue);
                            reportMessage(Severity.FIX, currentFeature.getOrigin(), MESSAGE_ID_REMOVED_SYNONYM, synonymValue, identifier);
                        }
                    }
                } else {
                    //this locus tag is now reserved by this set of gene synonyms
                    setMasterSynonymFeature(identifier2GeneSynonyms, identifier, currentFeature);
                }
            }
        }

        return result;
    }
260441
public void storeSkipExisting(Entry entry) throws MissingParentException {
        try {
            store(entry);
        } catch (EntryAlreadyExistsException e) {
            LOGGER.debug("Entry already exists. Skipping.");
        }
    }
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;
    }
222324
public static ValidationMessage shiftReferenceLocation(Entry entry,
			long newSequenceLength) {
		Collection<Reference> references = entry.getReferences();
		for (Reference reference : references) {
			for (Location rlocation : reference.getLocations().getLocations()) {
				{
					rlocation.setEndPosition(newSequenceLength);
					if (rlocation.getBeginPosition().equals(
							rlocation.getEndPosition())) {
						return ValidationMessage.message(Severity.WARNING,
								UTILS_6, rlocation.getBeginPosition(),
								rlocation.getEndPosition());
					}
				}
			}

		}
		return null;
	}
284610
public ValidationResult check(Entry entry) {
        result = new ValidationResult();

        if (entry == null) {
            return result;
        }

        //collect all gene features
        Collection<Feature> geneFeatures =
                SequenceEntryUtils.getFeatures(Feature.GENE_FEATURE_NAME, entry);

        if (geneFeatures.isEmpty()) {
            return result;
        }

        /**
         * which locus tag qualifiers are mapped to which gene features - should be an exclusive association
         */
        HashMap<String, Feature> locusTag2GeneFeature = new HashMap<String, Feature>();

        for (Feature geneFeature : geneFeatures) {

            List<Qualifier> locusQualifiers = geneFeature.getQualifiers(Qualifier.LOCUS_TAG_QUALIFIER_NAME);
            if (locusQualifiers.size() > 0) {

                String locus_tag_name = locusQualifiers.get(0).getValue();//got other checks for multiple locus_tags

                if (locusTag2GeneFeature.containsKey(locus_tag_name)) {
                    ValidationMessage<Origin> message =
                            reportError(result, geneFeature.getOrigin(), MESSAGE_ID, locus_tag_name);
                    message.append(locusTag2GeneFeature.get(locus_tag_name).getOrigin());
                } else {
                    locusTag2GeneFeature.put(locus_tag_name, geneFeature);
                }

            }
        }

        return result;
    }
715392
@Override
  public void addEntry(String logType, LogEntry entry) {
    if (!logTypesToInclude.contains(logType)) {
      return;
    }

    if (!localLogs.containsKey(logType)) {
      List<LogEntry> entries = new ArrayList<>();
      entries.add(entry);
      localLogs.put(logType, entries);
    } else {
      localLogs.get(logType).add(entry);
    }
  }
404052
@CanIgnoreReturnValue
  public Ordered containsExactlyEntriesIn(Map<?, ?> expectedMap) {
    if (expectedMap.isEmpty()) {
      if (actual().isEmpty()) {
        return IN_ORDER;
      } else {
        isEmpty(); // fails
        return ALREADY_FAILED;
      }
    }
    boolean containsAnyOrder =
        containsEntriesInAnyOrder(expectedMap, "contains exactly", /* allowUnexpected= */ false);
    if (containsAnyOrder) {
      return new MapInOrder(expectedMap, "contains exactly these entries in order");
    } else {
      return ALREADY_FAILED;
    }
  }
531290
static String encodeEntry(Entry<String, Point2d[]> entry) {
        StringBuilder sb = new StringBuilder();
        sb.append(entry.getKey());
        sb.append(' ');
        sb.append(encodeCoordinates(entry.getValue()));
        return sb.toString();
    }
1154592
private OriginalMapping getOriginalMappingForEntry(Entry entry) {
    if (entry.getSourceFileId() == UNMAPPED) {
      return null;
    } else {
      // Adjust the line/column here to be start at 1.
      Builder x = OriginalMapping.newBuilder()
        .setOriginalFile(sources[entry.getSourceFileId()])
        .setLineNumber(entry.getSourceLine() + 1)
        .setColumnPosition(entry.getSourceColumn() + 1);
      if (entry.getNameId() != UNMAPPED) {
        x.setIdentifier(names[entry.getNameId()]);
      }
      return x.build();
    }
  }
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)));
      }
    }
  }
79796
public void addEntry(String logType, LogEntry entry) {
    if (logTypesToIgnore.contains(logType)) {
      return;
    }

    if (!localLogs.containsKey(logType)) {
      localLogs.put(logType, Lists.newArrayList(entry));
    } else {
      localLogs.get(logType).add(entry);
    }
  }
87161
private static void checkNoConflictInValueBucket(
      Object value, Entry<?, ?> entry, @Nullable ImmutableMapEntry<?, ?> valueBucketHead) {
    for (; valueBucketHead != null; valueBucketHead = valueBucketHead.getNextInValueBucket()) {
      checkNoConflict(!value.equals(valueBucketHead.getValue()), "value", entry, valueBucketHead);
    }
  }
1078500
public static boolean isValid(String entry) {
		boolean result = true;

		try {
			shouldRun(entry);
		} catch (Exception ex) {
			result = false;
		}
		return result;
	}
183340
@Override
    public boolean contains(final ENTRY entry) throws CouldNotPerformException {
        if (entry == null) {
            throw new NotAvailableException("entry");
        }
        return contains(entry.getId());
    }
812079
@Override
    public boolean accept( final AuditLogEntry entry ) {
        if ( !acceptedTypes.containsKey( entry.getGenericType() ) ) {
            return false;
        }
        return acceptedTypes.get( entry.getGenericType() );
    }
756169
protected ValidationPlanResult validateEntry(Object entry) throws ValidationEngineException
	{

		ValidationPlanResult planResult = new ValidationPlanResult();

		String id = entry.toString();
		if (id == null)
		{
			id = "*";
		}

		printMessage(	id + ", ",LOG_LEVEL_ALL);
		switch(fileType)
		{
		case EMBL:
		case GENBANK:
		case FASTA:
			planResult = emblValidator.execute(entry); 
			break;
		case GFF3:
			planResult = gff3Validator.execute(entry);
			break;
		default:
			break;
						
		}
		return planResult;
	}
1128924
private void applyEntry(JournalEntry entry) {
    Preconditions.checkState(
        entry.getAllFields().size() <= 1
            || (entry.getAllFields().size() == 2 && entry.hasSequenceNumber()),
        "Raft journal entries should never set multiple fields in addition to sequence "
            + "number, but found %s",
        entry);
    if (entry.getJournalEntriesCount() > 0) {
      // This entry aggregates multiple entries.
      for (JournalEntry e : entry.getJournalEntriesList()) {
        applyEntry(e);
      }
    } else if (entry.getSequenceNumber() < 0) {
      // Negative sequence numbers indicate special entries used to indicate that a new primary is
      // starting to serve.
      mLastPrimaryStartSequenceNumber = entry.getSequenceNumber();
    } else if (entry.toBuilder().clearSequenceNumber().build()
        .equals(JournalEntry.getDefaultInstance())) {
      // Ignore empty entries, they are created during snapshotting.
    } else {
      applySingleEntry(entry);
    }
  }