Skip to content

Commit 3ee8c37

Browse files
Avoid duplicate join through precursors for transition queries (#889)
1 parent 2d8ffde commit 3ee8c37

4 files changed

Lines changed: 28 additions & 9 deletions

File tree

src/org/labkey/targetedms/TargetedMSSchema.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public FieldKey getContainerFieldKey()
317317
return FieldKey.fromParts("GeneralMoleculeChromInfoId", "GeneralMoleculeId", "PeptideGroupId", "RunId", "Container");
318318
}
319319
},
320-
GeneralPrecursorFK
320+
PrecursorFK
321321
{
322322
@Override
323323
public SQLFragment getSQL()
@@ -333,7 +333,26 @@ public SQLFragment getSQL()
333333
@Override
334334
public FieldKey getContainerFieldKey()
335335
{
336-
return FieldKey.fromParts("GeneralPrecursorId", "GeneralMoleculeId", "PeptideGroupId", "RunId", "Container");
336+
return FieldKey.fromParts("PrecursorId", "PeptideId", "PeptideGroupId", "RunId", "Container");
337+
}
338+
},
339+
MoleculePrecursorFK
340+
{
341+
@Override
342+
public SQLFragment getSQL()
343+
{
344+
SQLFragment sql = new SQLFragment();
345+
sql.append(makeInnerJoin(TargetedMSManager.getTableInfoGeneralPrecursor(), "pre", "GeneralPrecursorId"));
346+
sql.append(makeInnerJoin(TargetedMSManager.getTableInfoGeneralMolecule(), "gm", "pre.GeneralMoleculeId"));
347+
sql.append(makeInnerJoin(TargetedMSManager.getTableInfoPeptideGroup(), "pg", "gm.PeptideGroupId"));
348+
sql.append(getJoinToRunsTable("pg"));
349+
return sql;
350+
351+
}
352+
@Override
353+
public FieldKey getContainerFieldKey()
354+
{
355+
return FieldKey.fromParts("PrecursorId", "PeptideId", "PeptideGroupId", "RunId", "Container");
337356
}
338357
},
339358
GeneralTransitionFK
@@ -370,7 +389,7 @@ public FieldKey getContainerFieldKey()
370389
return FieldKey.fromParts("PrecursorChromInfoId", "Container");
371390
}
372391
},
373-
PrecursorFK
392+
SpectraLibraryPrecursorFK
374393
{
375394
@Override
376395
public SQLFragment getSQL()
@@ -385,7 +404,7 @@ public SQLFragment getSQL()
385404
@Override
386405
public FieldKey getContainerFieldKey()
387406
{
388-
return FieldKey.fromParts("PrecursorId", "GeneralMoleculeId", "PeptideGroupId", "RunId", "Container");
407+
return FieldKey.fromParts("PrecursorId", "PeptideId", "PeptideGroupId", "RunId", "Container");
389408
}
390409
},
391410
PrecursorTableFK
@@ -1495,7 +1514,7 @@ public DisplayColumn createRenderer(ColumnInfo colInfo)
14951514
TABLE_SPECTRAST_LIB_INFO.equalsIgnoreCase(name) ||
14961515
TABLE_CHROMATOGRAM_LIB_INFO.equalsIgnoreCase(name))
14971516
{
1498-
return new TargetedMSTable(getSchema().getTable(name), this, cf, ContainerJoinType.PrecursorFK);
1517+
return new TargetedMSTable(getSchema().getTable(name), this, cf, ContainerJoinType.SpectraLibraryPrecursorFK);
14991518
}
15001519

15011520
if (TABLE_KEYWORD_CATEGORIES.equalsIgnoreCase(name) ||

src/org/labkey/targetedms/query/AbstractGeneralTransitionTableInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929

3030
public class AbstractGeneralTransitionTableInfo extends JoinedTargetedMSTable
3131
{
32-
public AbstractGeneralTransitionTableInfo(final TargetedMSSchema schema, TableInfo tableInfo, ContainerFilter cf, boolean omitAnnotations)
32+
public AbstractGeneralTransitionTableInfo(final TargetedMSSchema schema, TableInfo tableInfo, ContainerFilter cf, boolean omitAnnotations, TargetedMSSchema.ContainerJoinType joinType)
3333
{
3434
super(TargetedMSManager.getTableInfoGeneralTransition(), tableInfo,
35-
schema, cf, TargetedMSSchema.ContainerJoinType.GeneralPrecursorFK,
35+
schema, cf, joinType,
3636
TargetedMSManager.getTableInfoTransitionAnnotation(), "TransitionId", omitAnnotations ? null : "Transition", "transition");
3737
}
3838

src/org/labkey/targetedms/query/DocTransitionsTableInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public DocTransitionsTableInfo(final TargetedMSSchema schema, ContainerFilter cf
4646

4747
public DocTransitionsTableInfo(final TargetedMSSchema schema, ContainerFilter cf, boolean omitAnnotations)
4848
{
49-
super(schema, TargetedMSManager.getTableInfoTransition(), cf, omitAnnotations);
49+
super(schema, TargetedMSManager.getTableInfoTransition(), cf, omitAnnotations, TargetedMSSchema.ContainerJoinType.PrecursorFK);
5050

5151
setDescription(TargetedMSManager.getTableInfoTransition().getDescription());
5252

src/org/labkey/targetedms/query/MoleculeTransitionsTableInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class MoleculeTransitionsTableInfo extends AbstractGeneralTransitionTable
3636
{
3737
public MoleculeTransitionsTableInfo(final TargetedMSSchema schema, ContainerFilter cf, boolean omitAnnotations)
3838
{
39-
super(schema, TargetedMSManager.getTableInfoMoleculeTransition(), cf, omitAnnotations);
39+
super(schema, TargetedMSManager.getTableInfoMoleculeTransition(), cf, omitAnnotations, TargetedMSSchema.ContainerJoinType.MoleculePrecursorFK);
4040

4141
setDescription(TargetedMSManager.getTableInfoMoleculeTransition().getDescription());
4242

0 commit comments

Comments
 (0)