lodash#intersectionWith TypeScript Examples

The following examples show how to use lodash#intersectionWith. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: filterByAminoacidChanges.ts    From nextclade with MIT License 6 votes vote down vote up
export function filterByAminoacidChanges(aaFilter: string) {
  const aaFilters = splitFilterString(aaFilter).map(parseAminoacidChange).filter(notUndefined)

  return (result: NextcladeResult) => {
    if (!result?.result) {
      return false
    }
    const { aaSubstitutions, aaDeletions } = result.result.analysisResult

    // Make deletions look like substitutions
    const aaDeletionsLikeSubstitutions = aaDeletions.map((del) => ({ ...del, queryAa: AMINOACID_GAP }))

    // We want to search for both, the substitutions and deletions
    const aaChanges = [...aaSubstitutions, ...aaDeletionsLikeSubstitutions]

    return intersectionWith(aaFilters, aaChanges, aminoacidChangesAreEqual).length > 0
  }
}
Example #2
Source File: filterByNucleotideMutations.ts    From nextclade with MIT License 6 votes vote down vote up
export function filterByNucleotideMutations(mutationsFilter: string) {
  const mutationFilters = splitFilterString(mutationsFilter).map(parseMutation).filter(notUndefined)

  return (result: NextcladeResult) => {
    if (!result?.result) {
      return false
    }
    const mutations = result.result.analysisResult.substitutions
    return intersectionWith(mutationFilters, mutations, mutationsAreEqual).length > 0
  }
}