@@ -24,12 +24,22 @@ import ShowHide from 'src/shared/components/show-hide/ShowHide';
2424import BlastHitsDiagram from 'src/content/app/tools/blast/components/blast-hits-diagram/BlastHitsDiagram' ;
2525import BlastSequenceAlignment from 'src/content/app/tools/blast/components/blast-sequence-alignment/BlastSequenceAlignment' ;
2626
27+ import {
28+ createCSVForGenomicBlast ,
29+ createCSVForProteinBlast ,
30+ createCSVForTranscriptBlast
31+ } from 'src/content/app/tools/blast/blast-download/createBlastCSVTable' ;
32+ import { downloadTextAsFile } from 'src/shared/helpers/downloadAsFile' ;
33+
2734import type {
2835 BlastHit ,
2936 BlastJobResult ,
3037 HSP
3138} from 'src/content/app/tools/blast/types/blastJob' ;
32- import type { BlastJobWithResults } from 'src/content/app/tools/blast/state/blast-results/blastResultsSlice' ;
39+ import type {
40+ BlastJobWithResults ,
41+ BlastSubmission
42+ } from 'src/content/app/tools/blast/state/blast-results/blastResultsSlice' ;
3343import type { Species } from 'src/content/app/tools/blast/state/blast-form/blastFormSlice' ;
3444import type { BlastSequenceAlignmentInput } from 'src/content/app/tools/blast/components/blast-sequence-alignment/blastSequenceAlignmentTypes' ;
3545import type { DatabaseType } from 'src/content/app/tools/blast/types/blastSettings' ;
@@ -48,7 +58,7 @@ type SingleBlastJobResultProps = {
4858 jobResult : BlastJobWithResults ;
4959 species : Species ;
5060 diagramWidth : number ;
51- blastDatabase : DatabaseType ;
61+ submission : BlastSubmission ;
5262} ;
5363
5464const hitsTableColumns : DataTableColumns = [
@@ -70,7 +80,12 @@ const hitsTableColumns: DataTableColumns = [
7080 title : 'Length' ,
7181 isSortable : true
7282 } ,
73- { width : '200px' , columnId : 'view_alignment' , isHideable : false } ,
83+ {
84+ width : '200px' ,
85+ columnId : 'view_alignment' ,
86+ isHideable : false ,
87+ isExportable : false
88+ } ,
7489 {
7590 width : '100px' ,
7691 columnId : 'percentage_id' ,
@@ -153,12 +168,7 @@ const hitsTableColumns: DataTableColumns = [
153168] ;
154169
155170const SingleBlastJobResult = ( props : SingleBlastJobResultProps ) => {
156- const {
157- species : speciesInfo ,
158- jobResult,
159- diagramWidth,
160- blastDatabase
161- } = props ;
171+ const { species : speciesInfo , jobResult, diagramWidth, submission } = props ;
162172 const [ isExpanded , setExpanded ] = useState ( false ) ;
163173
164174 const alignmentsCount = countAlignments ( jobResult . data ) ;
@@ -186,18 +196,21 @@ const SingleBlastJobResult = (props: SingleBlastJobResultProps) => {
186196 </ div >
187197
188198 { isExpanded && (
189- < HitsTable jobResult = { jobResult } blastDatabase = { blastDatabase } />
199+ < HitsTable jobResult = { jobResult } submission = { submission } />
190200 ) }
191201 </ div >
192202 ) ;
193203} ;
194204
195205type HitsTableProps = {
196206 jobResult : SingleBlastJobResultProps [ 'jobResult' ] ;
197- blastDatabase : DatabaseType ;
207+ submission : BlastSubmission ;
198208} ;
199209const HitsTable = ( props : HitsTableProps ) => {
200- const { jobResult, blastDatabase } = props ;
210+ const { jobResult, submission } = props ;
211+
212+ const blastDatabase = submission . submittedData . parameters
213+ . database as DatabaseType ;
201214
202215 const [ tableState , setTableState ] = useState < Partial < DataTableState > > ( {
203216 rowsPerPage : 100 ,
@@ -228,13 +241,12 @@ const HitsTable = (props: HitsTableProps) => {
228241 hitHsp . hsp_align_len ,
229242 '' , // view_alignment
230243 hitHsp . hsp_identity ,
231- hitHsp . hsp_score ,
232- < DynamicColumnContent
233- key = { counter }
234- hit = { hit }
235- blastDatabase = { blastDatabase }
236- hitHsp = { hitHsp }
237- /> ,
244+ hitHsp . hsp_bit_score ,
245+ getDynamicColumnContent ( {
246+ hit,
247+ blastDatabase,
248+ hitHsp
249+ } ) ,
238250 < span key = { counter } className = { styles . hitOrientation } >
239251 { hitHsp . hsp_hit_frame === '1' ? 'Forward' : 'Reverse' }
240252 </ span > ,
@@ -330,6 +342,19 @@ const HitsTable = (props: HitsTableProps) => {
330342 ) ;
331343 } ;
332344
345+ const downloadHandler = async ( ) => {
346+ let csv = '' ;
347+ if ( blastDatabase === 'dna' ) {
348+ csv = createCSVForGenomicBlast ( jobResult . data ) ;
349+ } else if ( blastDatabase === 'cdna' ) {
350+ csv = createCSVForTranscriptBlast ( jobResult . data ) ;
351+ } else if ( blastDatabase === 'pep' ) {
352+ csv = createCSVForProteinBlast ( jobResult . data ) ;
353+ }
354+
355+ await downloadTextAsFile ( csv , 'table.csv' ) ;
356+ } ;
357+
333358 return (
334359 < div className = { styles . tableWrapper } >
335360 < DataTable
@@ -341,9 +366,10 @@ const HitsTable = (props: HitsTableProps) => {
341366 expandedContent = { expandedContent }
342367 disabledActions = { [
343368 TableAction . FILTERS ,
344- TableAction . DOWNLOAD_ALL_DATA ,
369+ TableAction . FIND_IN_TABLE ,
345370 TableAction . DOWNLOAD_SHOWN_DATA
346371 ] }
372+ downloadHandler = { downloadHandler }
347373 />
348374 </ div >
349375 ) ;
@@ -373,7 +399,7 @@ type DynamicColumnContentProps = {
373399 blastDatabase : DatabaseType ;
374400} ;
375401
376- const DynamicColumnContent = ( props : DynamicColumnContentProps ) => {
402+ const getDynamicColumnContent = ( props : DynamicColumnContentProps ) => {
377403 const { hit, blastDatabase, hitHsp } = props ;
378404
379405 if ( blastDatabase !== 'dna' ) {
0 commit comments