99 LocationStartChange ,
1010} from '@apollo-annotation/shared'
1111import type { Assembly } from '@jbrowse/core/assemblyManager/assembly'
12+ import { readConfObject } from '@jbrowse/core/configuration'
1213import type { AbstractSessionModel } from '@jbrowse/core/util'
1314import { getSnapshot } from '@jbrowse/mobx-state-tree'
1415import {
@@ -30,6 +31,7 @@ import ObjectID from 'bson-objectid'
3031import React , { useEffect , useMemo , useState } from 'react'
3132
3233import type { ApolloSessionModel } from '../session'
34+ import { removeSkippedAttributes } from '../util'
3335
3436import { Dialog } from './Dialog'
3537
@@ -162,6 +164,11 @@ export function CreateApolloAnnotation({
162164 region,
163165} : CreateApolloAnnotationProps ) {
164166 const apolloSessionModel = session as unknown as ApolloSessionModel
167+ const configuredSkippedAttributes = readConfObject (
168+ apolloSessionModel . getPluginConfiguration ( ) ,
169+ 'skippedAttributesOnCopy' ,
170+ ) as string [ ] | undefined
171+ const skippedAttributesOnCopy = new Set ( configuredSkippedAttributes ?? [ ] )
165172 const { featureTypeOntology } =
166173 apolloSessionModel . apolloDataStore . ontologyManager
167174 const childIds = useMemo (
@@ -340,23 +347,28 @@ export function CreateApolloAnnotation({
340347
341348 // Copies gene feature along with its selected children
342349 const copyGeneFeature = async ( ) => {
350+ const copiedAnnotationFeature = {
351+ ...annotationFeature ,
352+ } as AnnotationFeatureSnapshot
353+ removeSkippedAttributes ( copiedAnnotationFeature , skippedAttributesOnCopy )
354+
343355 let change
344356 if (
345- annotationFeature . children &&
357+ copiedAnnotationFeature . children &&
346358 checkedChildrens . length !==
347- Object . values ( annotationFeature . children ) . length
359+ Object . values ( copiedAnnotationFeature . children ) . length
348360 ) {
349361 // IF SOME CHILDREN ARE CHECKED
350362 const childrens : Record < string , AnnotationFeatureSnapshot > = { }
351363 for ( const childId of checkedChildrens ) {
352- childrens [ childId ] = annotationFeature . children [ childId ]
364+ childrens [ childId ] = copiedAnnotationFeature . children [ childId ]
353365 }
354366 change = new AddFeatureChange ( {
355367 changedIds : [ annotationFeature . _id ] ,
356368 typeName : 'AddFeatureChange' ,
357369 assembly : assembly . name ,
358370 addedFeature : {
359- ...annotationFeature ,
371+ ...copiedAnnotationFeature ,
360372 children : childrens ,
361373 } ,
362374 } )
@@ -366,7 +378,7 @@ export function CreateApolloAnnotation({
366378 changedIds : [ annotationFeature . _id ] ,
367379 typeName : 'AddFeatureChange' ,
368380 assembly : assembly . name ,
369- addedFeature : annotationFeature ,
381+ addedFeature : copiedAnnotationFeature ,
370382 } )
371383 }
372384
@@ -380,7 +392,10 @@ export function CreateApolloAnnotation({
380392 return
381393 }
382394 for ( const transcriptId of Object . keys ( transcripts ) ) {
383- const transcript = transcripts [ transcriptId ]
395+ const transcript = {
396+ ...transcripts [ transcriptId ] ,
397+ } as AnnotationFeatureSnapshot
398+ removeSkippedAttributes ( transcript , skippedAttributesOnCopy )
384399 transcript . strand = selectedDestinationFeature . strand
385400
386401 // update strand of transcript children if they exist
@@ -405,9 +420,20 @@ export function CreateApolloAnnotation({
405420 const createNewGeneFeatureWithTranscripts = async (
406421 childrens : Record < string , AnnotationFeatureSnapshot > ,
407422 ) => {
423+ const copiedChildrens : Record < string , AnnotationFeatureSnapshot > = { }
424+ for ( const [ childId , child ] of Object . entries ( childrens ) ) {
425+ const copiedChild = { ...child } as AnnotationFeatureSnapshot
426+ removeSkippedAttributes ( copiedChild , skippedAttributesOnCopy )
427+ copiedChildrens [ childId ] = copiedChild
428+ }
429+
408430 const newGeneId = new ObjectID ( ) . toHexString ( )
409- const min = Math . min ( ...Object . values ( childrens ) . map ( ( child ) => child . min ) )
410- const max = Math . max ( ...Object . values ( childrens ) . map ( ( child ) => child . max ) )
431+ const min = Math . min (
432+ ...Object . values ( copiedChildrens ) . map ( ( child ) => child . min ) ,
433+ )
434+ const max = Math . max (
435+ ...Object . values ( copiedChildrens ) . map ( ( child ) => child . max ) ,
436+ )
411437 const change = new AddFeatureChange ( {
412438 changedIds : [ newGeneId ] ,
413439 typeName : 'AddFeatureChange' ,
@@ -419,7 +445,7 @@ export function CreateApolloAnnotation({
419445 max,
420446 strand : annotationFeature . strand ,
421447 type : 'gene' ,
422- children : childrens ,
448+ children : copiedChildrens ,
423449 attributes : {
424450 name : [ getGeneNameOrId ( annotationFeature ) ] ,
425451 gene_name : [ getGeneNameOrId ( annotationFeature ) ] ,
0 commit comments