@@ -11,16 +11,20 @@ import { SettingOutlined } from "@ant-design/icons";
1111
1212import { BENTO_PUBLIC_URL , BENTO_URL } from "@/config" ;
1313import { individualPropTypesShape } from "@/propTypes" ;
14- import { getIgvUrlsFromDrs } from "@/modules/drs/actions" ;
1514import { setIgvPosition } from "@/modules/explorer/actions" ;
1615import { useIgvGenomes } from "@/modules/explorer/hooks" ;
1716import { useReferenceGenomes } from "@/modules/reference/hooks" ;
1817import { useService } from "@/modules/services/hooks" ;
1918import { useAppDispatch , useAppSelector } from "@/store" ;
20- import { guessFileType } from "@/utils/files" ;
2119import { simpleDeepCopy } from "@/utils/misc" ;
2220
23- import { useDeduplicatedIndividualBiosamples } from "./utils" ;
21+ import {
22+ useDeduplicatedIndividualBiosamples ,
23+ ALIGNMENT_FORMATS_LOWER ,
24+ expResFileFormatLower ,
25+ isViewableInIgv ,
26+ expResFileFormatToIgvTypeAndFormat ,
27+ } from "./utils" ;
2428
2529const SQUISHED_CALL_HEIGHT = 10 ;
2630const EXPANDED_CALL_HEIGHT = 50 ;
@@ -51,39 +55,6 @@ const DEBOUNCE_WAIT = 500;
5155// verify url set is for this individual (may have stale urls from previous request)
5256const hasFreshUrls = ( files , urls ) => files . every ( ( f ) => urls . hasOwnProperty ( f . filename ) ) ;
5357
54- const ALIGNMENT_FORMATS_LOWER = [ "bam" , "cram" ] ;
55- const ANNOTATION_FORMATS_LOWER = [ "bigbed" ] ; // TODO: experiment result: support more
56- const MUTATION_FORMATS_LOWER = [ "maf" ] ;
57- const WIG_FORMATS_LOWER = [ "bigwig" ] ; // TODO: experiment result: support wig/bedGraph?
58- const VARIANT_FORMATS_LOWER = [ "vcf" , "gvcf" ] ;
59- const VIEWABLE_FORMATS_LOWER = [
60- ...ALIGNMENT_FORMATS_LOWER ,
61- ...ANNOTATION_FORMATS_LOWER ,
62- ...MUTATION_FORMATS_LOWER ,
63- ...WIG_FORMATS_LOWER ,
64- ...VARIANT_FORMATS_LOWER ,
65- ] ;
66-
67- const expResFileFormatLower = ( expRes ) => expRes . file_format ?. toLowerCase ( ) ?? guessFileType ( expRes . filename ) ;
68-
69- // For an experiment result to be viewable in IGV.js, it must have:
70- // - an assembly ID, so we can contextualize it correctly
71- // - a file format in the list of file formats we know how to handle
72- const isViewableInIgv = ( expRes ) =>
73- ! ! expRes . genome_assembly_id && VIEWABLE_FORMATS_LOWER . includes ( expResFileFormatLower ( expRes ) ) ;
74-
75- const expResFileFormatToIgvTypeAndFormat = ( fileFormat ) => {
76- const ff = fileFormat . toLowerCase ( ) ;
77-
78- if ( ALIGNMENT_FORMATS_LOWER . includes ( ff ) ) return [ "alignment" , ff ] ;
79- if ( ANNOTATION_FORMATS_LOWER . includes ( ff ) ) return [ "annotation" , "bigBed" ] ; // TODO: expand if we support more
80- if ( MUTATION_FORMATS_LOWER . includes ( ff ) ) return [ "mut" , ff ] ;
81- if ( WIG_FORMATS_LOWER . includes ( ff ) ) return [ "wig" , "bigWig" ] ; // TODO: expand if we support wig/bedGraph
82- if ( VARIANT_FORMATS_LOWER . includes ( ff ) ) return [ "variant" , "vcf" ] ;
83-
84- return [ undefined , undefined ] ;
85- } ;
86-
8758const TrackControlTable = memo ( ( { toggleView, allFoundFiles } ) => {
8859 const trackTableColumns = [
8960 {
@@ -151,20 +122,19 @@ const IGV_JS_ANNOTATION_ALIASES = {
151122const IndividualTracks = ( { individual } ) => {
152123 const accessToken = useAccessToken ( ) ;
153124
125+ const dispatch = useAppDispatch ( ) ;
154126 const igvDivRef = useRef ( ) ;
155127 const igvBrowserRef = useRef ( null ) ;
156128 const [ creatingIgvBrowser , setCreatingIgvBrowser ] = useState ( false ) ;
157129
158- const { igvUrlsByFilename : igvUrls , isFetchingIgvUrls } = useAppSelector ( ( state ) => state . drs ) ;
130+ const { urlsByFilename : igvUrls , isFetchingUrls : isFetchingIgvUrls } = useAppSelector ( ( state ) => state . drs ) ;
159131
160132 // read stored position only on first render
161133 const { igvPosition } = useAppSelector (
162134 ( state ) => state . explorer ,
163135 ( ) => true , // We don't want to re-render anything when the position changes
164136 ) ;
165137
166- const dispatch = useAppDispatch ( ) ;
167-
168138 const referenceService = useService ( "reference" ) ;
169139 // Built-in igv.js genomes (with annotations):
170140 const { hasAttempted : igvGenomesAttempted , itemsByID : igvGenomesByID } = useIgvGenomes ( ) ;
@@ -293,17 +263,6 @@ const IndividualTracks = ({ individual }) => {
293263 [ dispatch ] ,
294264 ) ;
295265
296- // retrieve urls on mount
297- useEffect ( ( ) => {
298- if ( allTracks . length ) {
299- // don't search if all urls already known
300- if ( hasFreshUrls ( allTracks , igvUrls ) ) {
301- return ;
302- }
303- dispatch ( getIgvUrlsFromDrs ( allTracks ) ) . catch ( console . error ) ;
304- }
305- } , [ dispatch , allTracks , igvUrls ] ) ;
306-
307266 // update access token whenever necessary
308267 useEffect ( ( ) => {
309268 if ( BENTO_URL ) {
0 commit comments