Skip to content

Commit

Permalink
adding option to filter off CDS translations to tidyUpSequenceData
Browse files Browse the repository at this point in the history
  • Loading branch information
tnrich committed Jun 15, 2022
1 parent b2f7012 commit 0f9ffcf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ve-sequence-utils",
"version": "5.1.18",
"version": "5.1.19",
"description": "sequence utility functions",
"main": "lib",
"//types": "./index.d.ts",
Expand Down
9 changes: 7 additions & 2 deletions src/tidyUpSequenceData.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// tnrtodo: figure out where to insert this validation exactly..
const bsonObjectid = require("bson-objectid");
const getAminoAcidDataForEachBaseOfDna = require("./getAminoAcidDataForEachBaseOfDna");
const { cloneDeep } = require("lodash");
const { cloneDeep, flatMap } = require("lodash");
const annotationTypes = require("./annotationTypes");
const filterSequenceString = require("./filterSequenceString");
const tidyUpAnnotation = require("./tidyUpAnnotation");
Expand All @@ -18,6 +18,7 @@ module.exports = function tidyUpSequenceData(pSeqData, options = {}) {
charOverrides,
doNotProvideIdsForAnnotations,
proteinFilterOptions,
noCdsTranslations,
convertAnnotationsFromAAIndices
} = options;
let seqData = cloneDeep(pSeqData); //sequence is usually immutable, so we clone it and return it
Expand Down Expand Up @@ -124,7 +125,11 @@ module.exports = function tidyUpSequenceData(pSeqData, options = {}) {
});

if (!noTranslationData) {
seqData.translations = seqData.translations.map(function(translation) {
seqData.translations = flatMap(seqData.translations, function(translation) {
if (noCdsTranslations && translation.translationType === "CDS Feature") {
//filter off cds translations
return [];
}
if (!translation.aminoAcids && !seqData.noSequence) {
translation.aminoAcids = getAminoAcidDataForEachBaseOfDna(
seqData.sequence,
Expand Down

0 comments on commit 0f9ffcf

Please sign in to comment.