Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/esckan-83 - Format CSV #85

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion applications/sckanner/frontend/src/models/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export interface KnowledgeStatement {

/**
*
* @type {Array<string>}
* @type {Sex}
* @memberof KnowledgeStatement
*/
sex: Sex;
Expand Down
35 changes: 25 additions & 10 deletions applications/sckanner/frontend/src/services/csvService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { KnowledgeStatement } from '../models/explorer';
import { Filters } from '../context/DataContext';
import { NEURONDM_VERSION, COMPOSER_VERSION } from '../settings';
import { KsRecord } from '../components/common/Types';

type csvData = {
[key: string]: KnowledgeStatement;
Expand Down Expand Up @@ -187,32 +188,39 @@ export const generateJourneyCsvService = (
];

const headers = [
'Connectivity Result',
'ID',
'Connection summary',
'Connection summary/Knowledge Statement',
'Species',
'Species ID',
'Sex',
'Origins (Names)',
'Origins (IDs)',
'Destinations (Names)',
'Destinations (IDs)',
'Sex ID',
'Origin',
'Origin ID',
'Destination',
'Destination IDs',
'Journey',
'Via ID',
'Phenotype',
'Laterality',
'Forward Connections',
'Synapses on',
'Target Organ',
'Forward Connection(s)',
'Synapses on (between first population and second)',
'TARGET Organ (final organ after forward connections)',
'Provenances',
];

const rows = [...metadata, headers];

Object.values(data).forEach((entry) => {
entry.journey.forEach((journey) => {
entry.journey.forEach((journey, index) => {
const row = [
index + 1,
entry.id,
entry.knowledge_statement,
entry.species.map((s) => s.name).join('; '),
entry.sex.name,
entry.species.map((s) => s.id).join('; '),
entry.sex.name || '',
D-GopalKrishna marked this conversation as resolved.
Show resolved Hide resolved
entry.sex.ontology_uri || '',
[...new Set(entry.origins.map((o) => o.name))].join('; '),
[...new Set(entry.origins.map((o) => o.id))].join('; '),
[
Expand All @@ -230,6 +238,13 @@ export const generateJourneyCsvService = (
),
].join('; '),
journey,
[
...new Set(
entry.vias.flatMap((via) =>
via.anatomical_entities.map((ae) => ae.id),
),
),
].join('; '),
entry.phenotype,
entry.laterality,
entry.forwardConnections.map((fc) => fc.reference_uri).join('; '),
Expand Down
2 changes: 1 addition & 1 deletion applications/sckanner/frontend/src/services/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function mapApiResponseToKnowledgeStatements(
laterality: ks.laterality || '',
projection: ks.projection || '',
circuit_type: ks.circuit_type || '',
sex: ks.sex || [],
sex: ks.sex || {},
afonsobspinto marked this conversation as resolved.
Show resolved Hide resolved
statement_preview: ks.statement_preview || '',
}));
}
Expand Down