final Map<String,Peptide> peptidePairIdToLabelledPeptide = addPeptides( gelFreeIdentification, mzData, matchedSpectrumReferences, peptidePairIdToPartnerPeptide, sharedPeptideSequences );
boolean quantified = false;
for( Map.Entry<String,Peptide> entry : peptidePairIdToLabelledPeptide.entrySet() )
{
final Peptide labelledPeptide = entry.getValue();
final List<Object> cvParamOrUserParam = labelledPeptide.getAdditional().getCvParamOrUserParam();
// Generate XIC:
final Spectrum labelledXic = xicFactory.getSpectrum( labelledPeptide );
final float labelledRt = Float.valueOf( PrideUtils.getCvParamValue( labelledPeptide.getAdditional(), PrideUtils.PARENT_ION_RETENTION_TIME_ACCESSION ) ).floatValue();
if( xicFactory.addPeakStartAndEnd( labelledXic, labelledRt ) )
{
// Add precursor spectrum:
double startRt = NumberUtils.UNDEFINED;
double endRt = NumberUtils.UNDEFINED;
for( final String comment : labelledXic.getSpectrumDesc().getComments() )
{
if( comment.startsWith( org.mcisb.massspectrometry.pride.converter.qconcat.PropertyNames.PEAK_START ) )
{
startRt = Double.parseDouble( comment.substring( org.mcisb.massspectrometry.pride.converter.qconcat.PropertyNames.PEAK_START.length() ) );
}
else if( comment.startsWith( org.mcisb.massspectrometry.pride.converter.qconcat.PropertyNames.PEAK_END ) )
{
endRt = Double.parseDouble( comment.substring( org.mcisb.massspectrometry.pride.converter.qconcat.PropertyNames.PEAK_END.length() ) );
}
}
final Spectrum[] precursorSpectra = precursorSpectrumFactory.getSpectra( labelledPeptide, startRt, endRt );
if( precursorSpectra.length > 0 )
{
quantified = true;
for( Spectrum precursorSpectrum : precursorSpectra )
{
spectra.add( precursorSpectrum );
matchedSpectrumReferences.add( Integer.valueOf( precursorSpectrum.getId() ) );
cvParamOrUserParam.add( PrideParamFactory.getUserParam( PrecursorSpectrumFactory.PRECURSOR_SPECTRUM_ID, Integer.toString( precursorSpectrum.getId() ) ) );
}
// Add XIC:
spectra.add( labelledXic );
matchedSpectrumReferences.add( Integer.valueOf( labelledXic.getId() ) );
cvParamOrUserParam.add( PrideParamFactory.getUserParam( XicFactory.XIC_ID, Integer.toString( labelledXic.getId() ) ) );
// Add quantitation:
cvParamOrUserParam.add( PrideParamFactory.getCvParam( PrideUtils.PRIDE_LABEL, PrideUtils.STABLE_ISOTOPE_RATIO_ACCESSION, "Stable isotope ratio", Double.toString( precursorSpectrumFactory.getRatio( labelledPeptide ) ) ) ); //$NON-NLS-1$
cvParamOrUserParam.add( PrideParamFactory.getUserParam( STABLE_ISOTOPE_RATIO_ACCESSION_ERROR_ID, Double.toString( precursorSpectrumFactory.getRatioStandardError( labelledPeptide ) ) ) );
cvParamOrUserParam.add( PrideParamFactory.getUserParam( NUM_OBSERVATIONS_ID, Long.toString( precursorSpectrumFactory.getNumberOfObservations( labelledPeptide ) ) ) );
// Add / find unlabelled peptide:
Peptide unlabelledPeptide = peptidePairIdToPartnerPeptide.get( entry.getKey() );
if( unlabelledPeptide != null )
{
for( Spectrum precursorSpectrum : precursorSpectra )
{
unlabelledPeptide.getAdditional().getCvParamOrUserParam().add( PrideParamFactory.getUserParam( PrecursorSpectrumFactory.PRECURSOR_SPECTRUM_ID, Integer.toString( precursorSpectrum.getId() ) ) );
}
}
else
{
unlabelledPeptide = PrideUtils.clone( labelledPeptide, labelAccessions );
unlabelledPeptide.setAdditional( new ParamType() );
unlabelledPeptide.getAdditional().getCvParamOrUserParam().add( PrideParamFactory.getCvParam( PrideUtils.PSI_LABEL, PrideUtils.PARENT_ION_CHARGE_STATE_ACCESSION, "Charge state", Long.toString( PrideUtils.getZ( labelledPeptide, mzData ) ) ) ); //$NON-NLS-1$
unlabelledPeptide.getAdditional().getCvParamOrUserParam().add( PrideParamFactory.getCvParam( PrideUtils.PRIDE_LABEL, PrideUtils.PARENT_ION_RETENTION_TIME_ACCESSION, "parent ion retention time", Float.toString( labelledRt ) ) ); //$NON-NLS-1$
gelFreeIdentification.getPeptideItem().add( unlabelledPeptide );
}
final Spectrum unlabelledXic = xicFactory.getSpectrum( unlabelledPeptide );
spectra.add( unlabelledXic );
matchedSpectrumReferences.add( Integer.valueOf( unlabelledXic.getId() ) );
unlabelledPeptide.getAdditional().getCvParamOrUserParam().add( PrideParamFactory.getUserParam( XicFactory.XIC_ID, Integer.toString( unlabelledXic.getId() ) ) );
unlabelledPeptide.getAdditional().getCvParamOrUserParam().add( PrideParamFactory.getCvParam( PrideUtils.PRIDE_LABEL, PrideUtils.PEPTIDE_PAIR_ID_ACCESSION, PEPTIDE_PAIR_ID_NAME, entry.getKey() ) );
}
}
}
if( !quantified )