Skip to content

Commit

Permalink
feat: deduplicate tracks based on filename (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Sep 8, 2023
1 parent a516250 commit 32e591b
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/components/explorer/IndividualTracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ TrackControlTable.propTypes = {
allFoundFiles: PropTypes.arrayOf(PropTypes.object),
};

// Right now, a lot of this code uses filenames. This should not be the case going forward,
// as multiple files may have the same name. Everything *should* be done through DRS IDs.
// For now, we treat the filenames as unique identifiers (unfortunately).

const IndividualTracks = ({ individual }) => {
const { accessToken } = useSelector((state) => state.auth);

Expand All @@ -102,17 +106,24 @@ const IndividualTracks = ({ individual }) => {

const viewableResults = useMemo(
() =>
experimentsData.flatMap((e) => e?.experiment_results ?? [])
.filter(isViewable)
.map((v) => { // add properties for visibility and file type
const fileFormat = v.file_format?.toLowerCase() ?? guessFileType(v.filename);
return {
...v,
// by default, don't view crams (user can turn them on in track controls):
viewInIgv: fileFormat !== "cram",
file_format: fileFormat, // re-formatted: to lowercase + guess if missing
};
}),
Object.values(
Object.fromEntries(
experimentsData.flatMap((e) => e?.experiment_results ?? [])
.filter(isViewable)
.map((v) => { // add properties for visibility and file type
const fileFormat = v.file_format?.toLowerCase() ?? guessFileType(v.filename);
return [
v.filename,
{
...v,
// by default, don't view crams (user can turn them on in track controls):
viewInIgv: fileFormat !== "cram",
file_format: fileFormat, // re-formatted: to lowercase + guess if missing
},
];
})
)
),
[experimentsData],
);

Expand Down

0 comments on commit 32e591b

Please sign in to comment.