Skip to content

Commit 56d1cc7

Browse files
committed
Merge branch 'v2.0' of github.com:unipept/unipept-desktop into v2.0
2 parents 419d8e1 + 2bdc376 commit 56d1cc7

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/logic/analysis/PeptideExport.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ export default class PeptideExport {
5555

5656
const pept2DataResponse = pept2data.get(peptide);
5757

58+
const sanitizeRegex = new RegExp(`${secondarySeparator}|${separator}`, "g");
59+
5860
if (!pept2DataResponse) {
5961
for (let i = 0; i < headerLength - 1; i++) {
6062
row.push("");
@@ -65,7 +67,7 @@ export default class PeptideExport {
6567
row.push(lcaDefinition ? lcaDefinition.name : "");
6668

6769
const processedLineage = pept2DataResponse.lineage.map(l => l ? ncbiOntology.getDefinition(l) : null);
68-
row.push(...processedLineage.map(l => l ? l.name : ""));
70+
row.push(...processedLineage.map(l => l ? l.name.replace(sanitizeRegex, "") : ""));
6971

7072
// Now add information about the EC-numbers.
7173
// This list contains the (EC-code, protein count)-mapping, sorted descending on counts.
@@ -79,11 +81,14 @@ export default class PeptideExport {
7981
const ecDefinitions: [EcDefinition, number][] = ecNumbers.map(c => [ecOntology.getDefinition(c[0]), c[1]]);
8082
row.push(
8183
ecDefinitions.map(
82-
c => `${c[0] ? c[0].name : ""} (${StringUtils.numberToPercent(c[1] / pept2DataResponse.faCounts.ec)})`
84+
c => `${c[0] ? c[0].name : ""} (${StringUtils.numberToPercent(c[1] / pept2DataResponse.faCounts.ec)})`.replace(sanitizeRegex, "")
8385
).join(secondarySeparator)
8486
);
8587

8688
// Now process the GO-terms
89+
const goCodes = [];
90+
const goNames = [];
91+
8792
for (const ns of Object.values(GoNamespace)) {
8893
const gos = pept2DataResponse.go;
8994
const goAnnotations = Object.keys(gos).filter(
@@ -98,30 +103,34 @@ export default class PeptideExport {
98103

99104
const sortedTerms = PeptideExport.sortAnnotations(goTerms);
100105

101-
row.push(
106+
goCodes.push(
102107
sortedTerms
103108
.map(a => `${a[0]} (${StringUtils.numberToPercent(a[1] / pept2DataResponse.faCounts.go)})`)
104109
.join(secondarySeparator)
105110
);
106111

107112
const goDefinitions: [GoDefinition, number][] = sortedTerms.map(c => [goOntology.getDefinition(c[0]), c[1]]);
108-
row.push(
113+
goNames.push(
109114
goDefinitions.map(
110-
c => `${c ? c[0].name : ""} (${StringUtils.numberToPercent(c[1] / pept2DataResponse.faCounts.go)})`
111-
).join(secondarySeparator));
115+
c => `${c ? c[0].name : ""} (${StringUtils.numberToPercent(c[1] / pept2DataResponse.faCounts.go)})`.replace(sanitizeRegex, "")
116+
).join(secondarySeparator)
117+
);
112118
}
113119

120+
row.push(...goCodes);
121+
row.push(...goNames);
122+
114123
// Now process the InterPro-terms
115124
const interproNumbers = PeptideExport.sortAnnotations(pept2DataResponse.ipr);
116125
row.push(
117126
interproNumbers
118-
.map(a => `${a[0].substr(4)} (${StringUtils.numberToPercent(a[1] / pept2DataResponse.faCounts.ipr)})`)
127+
.map(a => `${a[0].substr(4)} (${StringUtils.numberToPercent(a[1] / pept2DataResponse.faCounts.ipr)})`.replace(sanitizeRegex, ""))
119128
.join(secondarySeparator)
120129
);
121130

122131
const interproDefinitions: [InterproDefinition, number][] = interproNumbers.map(i => [iprOntology.getDefinition(i[0]), i[1]]);
123132
row.push(interproDefinitions.map(
124-
i => `${i && i[0] ? i[0].name : ""} (${StringUtils.numberToPercent(i[1] / pept2DataResponse.faCounts.ipr)})`
133+
i => `${i && i[0] ? i[0].name : ""} (${StringUtils.numberToPercent(i[1] / pept2DataResponse.faCounts.ipr)})`.replace(sanitizeRegex, "")
125134
).join(secondarySeparator));
126135
}
127136

0 commit comments

Comments
 (0)