Skip to content

Commit

Permalink
speeding up tidyUpAnnotation by passing featureTypes from tidyUpSeque…
Browse files Browse the repository at this point in the history
…nceData
  • Loading branch information
tnrich committed Mar 14, 2023
1 parent 834e309 commit 6e0ea2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/tidyUpAnnotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ module.exports = function tidyUpAnnotation(
doNotProvideIdsForAnnotations,
messages = [],
mutative,
allowNonStandardGenbankTypes
allowNonStandardGenbankTypes,
featureTypes
}
) {
const { size, circular, isProtein } = sequenceData;
Expand Down Expand Up @@ -86,7 +87,7 @@ module.exports = function tidyUpAnnotation(
if (
!annotation.type ||
typeof annotation.type !== "string" ||
!some(getFeatureTypes(), function(featureType) {
!some(featureTypes || getFeatureTypes(), function(featureType) {
if (featureType.toLowerCase() === annotation.type.toLowerCase()) {
annotation.type = featureType; //this makes sure the annotation.type is being set to the exact value of the accepted featureType
return true;
Expand Down
3 changes: 3 additions & 0 deletions src/tidyUpSequenceData.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const filterSequenceString = require("./filterSequenceString");
const tidyUpAnnotation = require("./tidyUpAnnotation");
const filterAminoAcidSequenceString = require("./filterAminoAcidSequenceString");
const getDegenerateDnaStringFromAaString = require("./getDegenerateDnaStringFromAAString");
const { getFeatureTypes } = require("./featureTypesAndColors");

module.exports = function tidyUpSequenceData(pSeqData, options = {}) {
const {
Expand Down Expand Up @@ -100,6 +101,7 @@ module.exports = function tidyUpSequenceData(pSeqData, options = {}) {
} else {
seqData.circular = true;
}
const featureTypes = getFeatureTypes();

annotationTypes.forEach(function(annotationType) {
if (!Array.isArray(seqData[annotationType])) {
Expand All @@ -116,6 +118,7 @@ module.exports = function tidyUpSequenceData(pSeqData, options = {}) {
seqData[annotationType] = seqData[annotationType].filter(annotation => {
return tidyUpAnnotation(annotation, {
...options,
featureTypes,
sequenceData: seqData,
convertAnnotationsFromAAIndices,
mutative: true,
Expand Down

0 comments on commit 6e0ea2d

Please sign in to comment.