614 bool op = saveSettings->getBoolValue( DATA_STATUS,
false );
617 kome::core::DataPoints tmpDps;
618 kome::core::DataPoints dps( kome::core::DataPoints::FLOAT );
620 spec.getXYData( &tmpDps, op );
621 for(
unsigned int i = 0; i < tmpDps.getLength(); i++ ) {
622 const double x = tmpDps.getX( i );
623 const double y = tmpDps.getY( i );
626 dps.addPoint( x, y );
631 const unsigned int len = dps.getLength();
633 float* xArr = (
float*)dps.getXData();
634 float* yArr = (
float*)dps.getYData();
636 for(
unsigned int i = 0; i < len; i++ ) {
637 memreverse( xArr + i,
sizeof(
float ) );
638 memreverse( yArr + i,
sizeof(
float ) );
652 std::string strSpotId;
654 if ( (
char *)NULL != spec.getSpotId( ) )
656 strSpotId = FMT(
"%s", spec.getSpotId( ) );
659 if ( 0 == strSpotId.length( ) )
663 "<spectrum id=\"%s\" index=\"%d\" defaultArrayLength=\"%d\">\n",
673 "<spectrum id=\"%s\" index=\"%d\" defaultArrayLength=\"%d\" spotID=\"%s\">\n",
684 kome::core::Properties& props = spec.getProperties();
686 if( spec.getMsStage() >= 1 ) {
689 " <cvParam cvRef=\"MS\" accession=\"MS:1000511\" name=\"ms level\" value=\"%d\"/>\n",
694 if( spec.isCentroidMode() ) {
695 fprintf( fp,
" <cvParam cvRef=\"MS\" accession=\"MS:1000127\" name=\"centroid spectrum\" value=\"\"/>\n" );
698 fprintf( fp,
" <cvParam cvRef=\"MS\" accession=\"MS:1000128\" name=\"profile spectrum\" value=\"\"/>\n" );
701 if( spec.getPolarity() == kome::objects::Spectrum::POLARITY_NEGATIVE ) {
702 fprintf( fp,
" <cvParam cvRef=\"MS\" accession=\"MS:1000129\" name=\"negative scan\" value=\"\"/>\n" );
704 else if( spec.getPolarity() == kome::objects::Spectrum::POLARITY_POSITIVE ) {
705 fprintf( fp,
" <cvParam cvRef=\"MS\" accession=\"MS:1000130\" name=\"positive scan\" value=\"\"/>\n" );
708 if( spec.getTotalIntensity() >= 0.0 ) {
711 " <cvParam cvRef=\"MS\" accession=\"MS:1000285\" name=\"total ion current\" value=\"%f\"/>\n",
712 spec.getTotalIntensity()
716 if( spec.getBasePeakMass() >= 0.0 ) {
719 " <cvParam cvRef=\"MS\" accession=\"MS:1000504\" name=\"base peak m/z\" value=\"%f\"/>\n",
720 spec.getBasePeakMass()
724 if( spec.getMaxIntensity() >= 0.0 ) {
727 " <cvParam cvRef=\"MS\" accession=\"MS:1000505\" name=\"base peak intensity\" value=\"%f\"/>\n",
728 spec.getMaxIntensity()
735 " <scanList count=\"1\">\n"
738 std::string instrument = spec.getSample()->getInstrument();
739 if( instrument.empty() ) {
740 instrument =
"undefined";
748 std::string filter = props.getStringValue(
"Filter",
"" );
749 if( !filter.empty() ) {
752 " <cvParam cvRef=\"MS\" accession=\"MS:1000512\" name=\"filter string\" value=\"%s\"/>\n",
757 if( spec.getRt() >= 0.0 ) {
760 " <cvParam cvRef=\"MS\" accession=\"MS:1000016\" name=\"scan start time\" value=\"%f\"\n",
766 " unitCvRef=\"UO\" unitAccession=\"UO:0000031\" unitName=\"minute\"/>\n"
772 " <scanWindowList count=\"1\">\n"
780 if( spec.getMinX() >= 0.0 ) {
783 " <cvParam cvRef=\"MS\" accession=\"MS:1000501\" name=\"scan window lower limit\" value=\"%f\"/>\n",
787 if( spec.getMaxX() >= 0.0 ) {
790 " <cvParam cvRef=\"MS\" accession=\"MS:1000500\" name=\"scan window upper limit\" value=\"%f\"/>\n",
802 " </scanWindowList>\n"
816 const double precursor = spec.getPrecursor();
817 if( precursor >= 0.0 ) {
818 kome::objects::Spectrum* parent = spec.getParentSpectrum();
819 std::string parentId = ( parent == NULL ?
"" : parent->getName() );
823 " <precursorList count=\"1\">\n"
828 " <precursor spectrumRef=\"%s\">\n",
834 " <selectedIonList count=\"1\">\n"
844 " <cvParam cvRef=\"MS\" accession=\"MS:1000744\" name=\"selected ion m/z\"\n"
849 " value=\"%f\" unitCvRef=\"MS\" unitAccession=\"MS:1000040\" unitName=\"m/z\"/>\n",
860 " </selectedIonList>\n"
870 " </precursorList>\n"
877 unsigned long buffLength = len *
sizeof( float ) * 2;
878 char* base64Buff =
new char[ buffLength ];
880 fprintf( fp,
" <binaryDataArrayList count=\"2\">\n" );
883 unsigned long size = kome::core::Base64::encode( dps.getXData(),
sizeof( float ) * len, base64Buff, buffLength );
885 fprintf( fp,
" <binaryDataArray encodedLength=\"%d\">\n", size );
887 #ifdef MZML_USE_REFERENCEABLE_PARAM_GROUP
888 fprintf( fp,
" <referenceableParamGroupRef ref=\"mz_params\"/>\n" );
890 fprintf( fp,
" <cvParam cvRef=\"MS\" accession=\"MS:1000514\" name=\"m/z array\" value=\"\"\n" );
891 fprintf( fp,
" unitCvRef=\"MS\" unitAccession=\"MS:1000040\" unitName=\"m/z\"/>\n" );
892 fprintf( fp,
" <cvParam cvRef=\"MS\" accession=\"MS:1000521\" name=\"32-bit float\" value=\"\"/>\n" );
893 fprintf( fp,
" <cvParam cvRef=\"MS\" accession=\"MS:1000576\" name=\"no compression\" value=\"\"/>\n" );
894 #endif // MZML_USE_REFERENCEABLE_PARAM_GROUP
896 fprintf( fp,
" <binary>" );
899 char* pos = base64Buff;
901 int writeSize = MIN( size, 1024 );
902 writeSize = fwrite( pos, 1, writeSize, fp );
907 fprintf( fp,
"</binary>\n" );
908 fprintf( fp,
" </binaryDataArray>\n" );
911 size = kome::core::Base64::encode( dps.getYData(),
sizeof( float ) * len, base64Buff, buffLength );
913 fprintf( fp,
" <binaryDataArray encodedLength=\"%d\">\n", size );
915 #ifdef MZML_USE_REFERENCEABLE_PARAM_GROUP
916 fprintf( fp,
" <referenceableParamGroupRef ref=\"int_params\"/>\n" );
918 fprintf( fp,
" <cvParam cvRef=\"MS\" accession=\"MS:1000515\" name=\"intensity array\" value=\"\"/>\n" );
919 fprintf( fp,
" <cvParam cvRef=\"MS\" accession=\"MS:1000521\" name=\"32-bit float\" value=\"\"/>\n" );
920 fprintf( fp,
" <cvParam cvRef=\"MS\" accession=\"MS:1000576\" name=\"no compression\" value=\"\"/>\n" );
921 #endif // MZML_USE_REFERENCEABLE_PARAM_GROUP
923 fprintf( fp,
" <binary>" );
927 int writeSize = MIN( size, 1024 );
928 writeSize = fwrite( pos, 1, writeSize, fp );
933 fprintf( fp,
"</binary>\n" );
934 fprintf( fp,
" </binaryDataArray>\n" );
936 fprintf( fp,
" </binaryDataArrayList>\n" );
942 fprintf( fp,
" </spectrum>\n" );
std::map< kome::objects::Spectrum *, long long > m_specIdxMap