Пример #1
0
int PASCAL WinMain( HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show )
{
    char buffer[PATH_MAX];

#if !defined( __WATCOMC__ ) && defined( __NT__ )
    _argc = __argc;
    _argv = __argv;
#endif
    EXEName = _cmdname( buffer );
    InstanceHandle = inst;
    showHow = show;
    prev = prev;
    cmdline = cmdline;

    InitMem();

#ifndef __NT__
    if( prev != NULL && !HasShare() ) {
        MessageBox( NULLHANDLE, "SHARE.EXE must be loaded before starting Windows in order to run multiple instances of the editor",
                    EditorName, MB_OK );
        MyGetInstanceData( (unsigned short) prev, (void near *) &Root, sizeof( Root ) );
        SetFocus( Root );
        return( 0 );
    }
#endif

    Comspec = getenv( "COMSPEC" );
#ifdef __NT__
    VarAddGlobalStr( "OS", "winnt" );
#else
    VarAddGlobalStr( "OS", "win" );
#endif
    SetConfigFileName( CFG_NAME );
    ReadProfile();

    ShowStartupDialog();

    initApplication();
    if( !initInstance() ) {
        return( 0 );
    }
    InitializeEditor();
    SetSaveConfig();
    if( !BAD_ID( CurrentWindow ) ) {
        SetFocus( Root );
    }

    SetWindowCursorForReal();
    ResizeRoot();
    EditMain();

    FiniMem();

    return( 0 );

} /* WinMain */
void CIV_Data_Update_Service::Load(void)
{
	ReadProfile() ;
	try
	{
	
		m_DbInterface.Connect() ;
	}
	catch (  _com_error )
	{
		//ATLASSERT ( !"Can't open Data Base" ) ;
	}
}
Пример #3
0
static void OnLoadClicked(WindowControl * Sender){

 TCHAR file_name[MAX_PATH];

  WndProperty* wp;
  DataFieldFileReader *dfe;

  wp = (WndProperty*)wf->FindByName(TEXT("prpFile"));
  if (!wp) return;

  HWND hwnd = wp->GetHandle();
  SendMessage(hwnd,WM_LBUTTONDOWN,0,0);
  dfe = (DataFieldFileReader*) wp->GetDataField();

  int file_index = dfe->GetAsInteger();
  if (file_index>0) {
	_tcscpy(file_name,dfe->GetAsString());

	if(MessageBoxX(hWndMapWindow, file_name, 
	// LKTOKEN  _@M397_ = "Load this profile?" 
		gettext(TEXT("_@M397_")), 
		MB_YESNO|MB_ICONQUESTION) == IDYES) {
		SettingsEnter();
		ReadProfile(dfe->GetPathFile());
		WAYPOINTFILECHANGED=true;
		SettingsLeave();
		MessageBoxX(hWndMapWindow, 
	// LKTOKEN  _@M534_ = "Profile loaded!" 
		gettext(TEXT("_@M534_")),
		_T(""), MB_OK|MB_ICONEXCLAMATION);
		return;
	}
  	dfe->Set(0);
  }
  
}
Пример #4
0
/* - isochores are specific DNA regions according to the G+C content - */
void ReadIsochore(FILE* RootFile, gparam* gp)
{
  float lscore;       
  int OligoLength_1;
  int i,j,f;
  char line[MAXLINE];
  char mess[MAXSTRING];
  char header[MAXSTRING];
  
  /* 1. read boundaries of isochores */
  readHeader(RootFile,line);
  readLine(RootFile,line);

  if ((sscanf(line,"%d %d\n", 
			  &(gp->leftValue),
			  &(gp->rightValue)))!=2)
    printError("Wrong format: isochore boundaries (G+C percent)");

  sprintf(mess,"Isochores boundaries(min/max percentage): %d,%d", 
		  gp->leftValue,
		  gp->rightValue);
  printMess(mess); 

  /* 2. read cutoff (final score) to accept one predicted exon */
  readHeader(RootFile,line);
  readLine(RootFile,line);

  if ((sscanf(line,"%f %f %f %f %f\n",
			  &(gp->Initial->ExonCutoff),
			  &(gp->Internal->ExonCutoff),
			  &(gp->Terminal->ExonCutoff),
	                  &(gp->Single->ExonCutoff),
			  &(gp->utr->ExonCutoff)))< 4)
    printError("Wrong format: exon score cutoffs (number/type)");  

  sprintf(mess,"Exon cutoffs: \t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f",
		  gp->Initial->ExonCutoff,
		  gp->Internal->ExonCutoff,
		  gp->Terminal->ExonCutoff,
	          gp->Single->ExonCutoff,
	          gp->utr->ExonCutoff);
  printMess(mess); 

  /* 3. read cutoff (potential coding score) to accept one predicted exon */
  readHeader(RootFile,line);
  readLine(RootFile,line);
  if ((sscanf(line,"%f %f %f %f\n",     
			  &(gp->Initial->OligoCutoff),
			  &(gp->Internal->OligoCutoff),
			  &(gp->Terminal->OligoCutoff),
			  &(gp->Single->OligoCutoff)))!=4)
    printError("Wrong format: potential coding score cutoffs (number/type)");  
  
  sprintf(mess,"Oligo cutoffs: \t%9.3f\t%9.3f\t%9.3f\t%9.3f",
		  gp->Initial->OligoCutoff,
		  gp->Internal->OligoCutoff,
		  gp->Terminal->OligoCutoff,
		  gp->Single->OligoCutoff);
  printMess(mess); 

  /* 4. Weight of signals in final exon score */
  readHeader(RootFile,line);
  readLine(RootFile,line);
  if ((sscanf(line,"%f %f %f %f %f\n",
			  &(gp->Initial->siteFactor),
			  &(gp->Internal->siteFactor),
			  &(gp->Terminal->siteFactor),
			  &(gp->Single->siteFactor),
			  &(gp->utr->siteFactor)))<4)
	printError("Wrong format: weight of signal scores (number/type)");  
  
  sprintf(mess,"Site factors: \t%9.2f\t%9.2f\t%9.2f\t%9.2f\t%9.2f",
		  gp->Initial->siteFactor,
		  gp->Internal->siteFactor,
		  gp->Terminal->siteFactor,
	          gp->Single->siteFactor,
	          gp->utr->siteFactor);
  printMess(mess); 

  /* 5. Weight of coding potential in final exon score */
  readHeader(RootFile,line);
  readLine(RootFile,line);
  if ((sscanf(line,"%f %f %f %f\n",
			  &(gp->Initial->exonFactor),
			  &(gp->Internal->exonFactor),
			  &(gp->Terminal->exonFactor),
			  &(gp->Single->exonFactor)))<4)
	printError("Wrong format: weight of coding potential scores (number/type)");  
  
  sprintf(mess,"Exon factors: \t%9.2f\t%9.2f\t%9.2f\t%9.2f",
		  gp->Initial->exonFactor,
		  gp->Internal->exonFactor,
		  gp->Terminal->exonFactor,
		  gp->Single->exonFactor);
  printMess(mess); 

  /* 6. Weight of homology information in final exon score */
  readHeader(RootFile,line);
  readLine(RootFile,line);
  if ((sscanf(line,"%f %f %f %f %f\n",
			  &(gp->Initial->HSPFactor),
			  &(gp->Internal->HSPFactor),
			  &(gp->Terminal->HSPFactor),
			  &(gp->Single->HSPFactor),
			  &(gp->utr->HSPFactor)))<4)

	printError("Wrong format: weight of homology scores (number/type)");  
  
  sprintf(mess,"HSP factors: \t\t%9.2f\t%9.2f\t%9.2f\t%9.2f\t%9.2f",
		  gp->Initial->HSPFactor,
		  gp->Internal->HSPFactor,
		  gp->Terminal->HSPFactor,
		  gp->Single->HSPFactor,
		  gp->utr->HSPFactor);
  printMess(mess); 

  /* 7. read weights to correct the score of exons after general cutoff */
  readHeader(RootFile,line);
   if ((sscanf(line,"%s",header))!=1)
		{
		  sprintf(mess,"Wrong format: header for exon weights and optional U12 score threshold");
		  printError(mess);
		}
  while(strcasecmp(header,sExon_weights)&& strcmp(header,"Exon_weigths"))
  { 
	 /* 1. Read RSSMARKOVSCORE for markov score to assign non-exonic recursively spliced elements */
	if(!strcasecmp(header,sRSSMARKOVSCORE)){
		  readLine(RootFile,line);
		  if ((sscanf(line,"%f\n", &(RSSMARKOVSCORE)))!=1)
			printError("Wrong format: RSSMARKOVSCORE value scores (number/type)");  

		  sprintf(mess,"RSSMARKOVSCORE: \t%9.2f",RSSMARKOVSCORE);
		  printMess(mess);
	}
	 /* 1. Read Evidence Exon Weight */
	if(!strcasecmp(header,sEVIDENCEW)){
		  readLine(RootFile,line);
		  if ((sscanf(line,"%f\n", &(EvidenceEW)))!=1)
			printError("Wrong format: EvidenceExonWeight value (number/type)");  

		  sprintf(mess,"EvidenceExonWeight: \t%9.2f",EvidenceEW);
		  printMess(mess);
	}
	 /* 1. Read Evidence Exon Factor */
	if(!strcasecmp(header,sEVIDENCEF)){
		  readLine(RootFile,line);
		  if ((sscanf(line,"%f\n", &(EvidenceFactor)))!=1)
			printError("Wrong format: EvidenceFactor value (number/type)");  

		  sprintf(mess,"EvidenceFactor: \t%9.2f",EvidenceFactor);
		  printMess(mess);
	}
	 /* 1. Read RSS_Donor_Score_Cutoff */
	if(!strcasecmp(header,sRSS_DONOR_SCORE_CUTOFF)){
		  readLine(RootFile,line);
		  if ((sscanf(line,"%f\n", &(RSSDON)))!=1)
			printError("Wrong format: RSSDON value scores (number/type)");  

		  sprintf(mess,"RSSDON: \t%9.2f",RSSDON);
		  printMess(mess);
	}
	 /* 1. Read RSSMARKOVSCORE for markov score to assign non-exonic recursively spliced elements */
	if(!strcasecmp(header,sRSS_ACCEPTOR_SCORE_CUTOFF)){
		  readLine(RootFile,line);
		  if ((sscanf(line,"%f\n", &(RSSACC)))!=1)
			printError("Wrong format: RSSACC value scores (number/type)");  

		  sprintf(mess,"RSSACC: \t%9.2f",RSSACC);
		  printMess(mess);
	}
	 /* 1. Read U12_SPLICE_SCORE_THRESH for sum of U12 donor and acceptor splice scores */
	if(!strcasecmp(header,sU12_SPLICE_SCORE_THRESH)){
		  readLine(RootFile,line);
		  if ((sscanf(line,"%f\n", &(U12_SPLICE_SCORE_THRESH)))!=1)
			printError("Wrong format: U12_SPLICE_SCORE_THRESH value scores (number/type)");  

		  sprintf(mess,"U12_SPLICE_SCORE_THRESH: \t%9.2f",
				  U12_SPLICE_SCORE_THRESH);
		  printMess(mess);
	}
	 /* 1. Read U12_EXON_SCORE_THRESH for sum of U12 donor and acceptor exon scores */
	if(!strcasecmp(header,sU12_EXON_SCORE_THRESH)){
		  readLine(RootFile,line);
		  if ((sscanf(line,"%f\n", &(U12_EXON_SCORE_THRESH)))!=1)
			printError("Wrong format: U12_EXON_SCORE_THRESH value scores (number/type)");  

		  sprintf(mess,"U12_EXON_SCORE_THRESH: \t%9.2f",
				  U12_EXON_SCORE_THRESH);
		  printMess(mess);
	}
	 /* 1. Read U12_EXON_WEIGHT, an additional exon weight that applies to exons flanking U12 introns */
	if(!strcasecmp(header,sU12_EXON_WEIGHT)){
		  readLine(RootFile,line);
		  if ((sscanf(line,"%f\n", &(U12EW)))!=1)
			printError("Wrong format: U12_EXON_WEIGHT value score (number/type)");  

		  sprintf(mess,"U12_EXON_WEIGHT: \t%9.2f",
				  U12EW);
		  printMess(mess);
	}
	readHeader(RootFile,line);
	if ((sscanf(line,"%s",header))!=1)
		{
		  sprintf(mess,"Wrong format: header for exon weights");
		  printError(mess);
		}
  }
  readLine(RootFile,line);
  if ((sscanf(line,"%f %f %f %f %f\n",
			  &(gp->Initial->ExonWeight),
			  &(gp->Internal->ExonWeight),
			  &(gp->Terminal->ExonWeight),
			  &(gp->Single->ExonWeight),
			  &(gp->utr->ExonWeight)))<4)
    printError("Wrong format: exon weight values (number/type)");  

  sprintf(mess,"Exon weights: \t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f",
		  gp->Initial->ExonWeight,
		  gp->Internal->ExonWeight,
		  gp->Terminal->ExonWeight,
		  gp->Single->ExonWeight,
		  gp->utr->ExonWeight);
  printMess(mess);

 
  /* 8. Read splice site profiles */
  /* (a).start codon profile */
  ReadProfile(RootFile, gp->StartProfile , sSTA,1);

  /* (b).acceptor and donor site profiles */
  ReadProfileSpliceSites(RootFile, gp);

  /* (c).donor site profile */
  /* ReadProfile(RootFile, gp->DonorProfile , sDON,1); */

  /* (d).stop codon profile */
  ReadProfile(RootFile, gp->StopProfile , sSTO,1);
  
  /* 9. read coding potential log-likelihood values (Markov chains) */
  readHeader(RootFile,line);   
  if ((sscanf(line,"%s",header))!=1)
    {
      sprintf(mess,"Wrong format: header ");
      printError(mess);
      printMess(header);
    }


  while(strcasecmp(header,sMarkov)&&strcasecmp(header,"Markov_oligo_logs_file"))
    {
      /* printMess(header); */
      
      
      if (!strcasecmp(header,sprofilePolyA))
	{

	  PAS++;
	  printMess("Reading PolyA Signal Profile");
	  /* Reading the U2gty donor profile */
	  ReadProfile(RootFile, gp->PolyASignalProfile, sPOL, 0);
	  
	}
      
      readHeader(RootFile,line);
      if ((sscanf(line,"%s",header))!=1)
	{
	  sprintf(mess,"Wrong format: header ");
	  printError(mess);
	  printMess(header);
	}
  }      
  /* Next profile for Markov order */
  readLine(RootFile,line);

  if ((sscanf(line,"%d", &(gp->OligoLength)))!=1)
    printError("Wrong format: oligonucleotide length");

  sprintf(mess,"Oligonucleotide (word) length: %d",gp->OligoLength);
  printMess(mess);

  /* (a). Initial probability matrix */
  printMess("Reading Markov Initial likelihood matrix");

  /* Computing the right number of initial values to read */      
  gp->OligoDim=(int)pow((float)4,(float)gp->OligoLength);

  sprintf(mess,"Used oligo array size: %ld",gp->OligoDim * 3);
  printMess(mess);

  readHeader(RootFile,line);
  for(j = 0; j < gp->OligoDim * 3; j++)
    { 
      readLine(RootFile,line); 
      if ((sscanf(line, "%*s %d %d %f", &i, &f, &lscore))!=3)
        {
          sprintf(mess, "Wrong format/nunber (%s): Initial Markov value", line);
          printError(mess);
        }
      gp->OligoLogsIni[f][i]=lscore;
    }

  /* (b). Transition probability matrix */
  printMess("Reading Markov Transition likelihood matrix");

  OligoLength_1= gp->OligoLength + 1;
  gp->OligoDim_1=(int)pow((float)4,(float)OligoLength_1);

  sprintf(mess,"Used oligo array size: %ld",gp->OligoDim_1 * 3);
  printMess(mess);

  readHeader(RootFile,line);
  for(j = 0; j < gp->OligoDim_1 * 3; j++)
    { 
      readLine(RootFile,line); 
      if ((sscanf(line, "%*s %d %d %f", &i, &f, &lscore))!=3)
        {
          sprintf(mess, "Wrong format/number (%s): Transition Markov value", line);
          printError(mess);
        }
      gp->OligoLogsTran[f][i]=lscore;
    }

  /* 10. read maximum number of donors per acceptor site (BuildExons) */
  readHeader(RootFile,line);
  readLine(RootFile,line); 
  
  if ((sscanf(line,"%d", &(gp->MaxDonors)))!=1)
    printError("Bad format: MaxDonors value");   
    
  sprintf(mess,"Maximum donors by acceptor = %d\n", gp->MaxDonors);
  printMess(mess);
}
Пример #5
0
/* Read information useful to predict Acceptor splice sites */
void ReadProfileSpliceSites(FILE* RootFile, gparam* gp)
{
  char line[MAXLINE];
  char mess[MAXSTRING];
  char header[MAXSTRING];
  profile* p;
  int u12bp=0;
  int u12gtagAcc=0;
  int u12atacAcc=0;
  int u12gtagDon=0;
  int u12atacDon=0;


  /* A. Optional profiles: U12GTAG, U12ATAC Donor, acceptor and branch points 
  and U2 branch points and Poly Pyrimidine Tract */
  
  readHeader(RootFile,line);
  if ((sscanf(line,"%s",header))!=1)
	{
	  sprintf(mess,"Wrong format: header in optional profile for splice sites");
	  printError(mess);
	}

  while(strcasecmp(header,sprofileACC))
	{ 
	
	/* Read optional profiles: sprofilePPT,sprofileBP,sprofileU12BP,sprofileU12gtagACC,sprofileU12atacACC */ 

	  if (!strcasecmp(header,sprofileU12BP))
		{
		  	u12bp++;

		  	/* Reading the U12 Branch Point profile */
		  	p = gp->U12BranchPointProfile;
		  	ReadProfile(RootFile, p, sBP, 0);
		}
	  	else
		  {
		  	if (!strcasecmp(header,sprofileU12gtagACC))
			  {
			  	u12gtagAcc++;

			  	/* Reading the U12gtag acceptor profile */
			  	p = gp->U12gtagAcceptorProfile;
			  	ReadProfile(RootFile, p, sACC, 0);
			  }
			  else
				{
			  	  if (!strcasecmp(header,sprofileU12atacACC))
					{	
				  	  u12atacAcc++;

				  	  /* Reading the U12atac acceptor profile */
				  	  p = gp->U12atacAcceptorProfile;
				  	  ReadProfile(RootFile, p, sACC, 0);
					}
					else
					  {
						if (!strcasecmp(header,sprofilePPT))
						  {
					  		/* Switch on the acceptor prediction using PPTs */
					  		PPT++;

					  		/* Reading the Poly Pyrimidine Tract profile */
					  		p = gp->PolyPTractProfile;
					  		ReadProfile(RootFile, p, sPPT, 0);
						  }
				  		  else
							{
					   		  if (!strcasecmp(header,sprofileBP))
								{
						  		  /* Switch on the acceptor prediction using BPs */
						  		  BP++;

						  		  /* Reading the Branch Point profile */
						  		  p = gp->BranchPointProfile;
						  		  ReadProfile(RootFile, p, sBP, 0);
								}
					  			else
								  {
						  			sprintf(mess,"Wrong format: profile name %s \n\tis not admitted for acceptors [only %s, %s, %s, %s, %s or %s]",
								  	header, sprofileACC, sprofilePPT, sprofileBP, sprofileU12BP, sprofileU12gtagACC, sprofileU12atacACC);
						  			printError(mess);
								  }
							}
					  }
				}
		  }

	  /* Next profile for acceptor site */
	  readHeader(RootFile,line);
	  if ((sscanf(line,"%s",header))!=1)
		{
		  sprintf(mess,"Wrong format: header in optional profile for acceptor sites");
		  printError(mess);
		}
	}

  /* Reading the Acceptor site profile */
  p = gp->AcceptorProfile;
  ReadProfile(RootFile, p, sACC, 0);
  
  readHeader(RootFile,line);
  if ((sscanf(line,"%s",header))!=1)
    {
      sprintf(mess,"Wrong format: header in optional profile for splice sites");
      printError(mess);
    }

  /* Read optional profiles: sprofileU12gtagDON,sprofileU12atacDON */
  
  while(strcasecmp(header,sprofileDON))
    { 

      if (!strcasecmp(header,sprofileU12gtagDON))
	{

	  u12gtagDon++;

	  /* Reading the U12gtag donor profile */
	  p = gp->U12gtagDonorProfile;
	  ReadProfile(RootFile, p, sDON, 0);
	}
      else
	{
	  if (!strcasecmp(header,sprofileU12atacDON))
	    {

	      u12atacDon++;

	      /* Reading the U12atac donor profile */
	      p = gp->U12atacDonorProfile;
	      ReadProfile(RootFile, p, sDON, 0);
	    }
	  else
	    {
	      if (!strcasecmp(header,sprofileU2gcagDON))
		{

		  U2GCAG++;

		  /* Reading the U2gcag donor profile */
		  p = gp->U2gcagDonorProfile;
		  ReadProfile(RootFile, p, sDON, 0);
		}
	      else
		{
		  if (!strcasecmp(header,sprofileU2gtaDON))
		    {

		      U2GTA++;

		      /* Reading the U2gta donor profile */
		      p = gp->U2gtaDonorProfile;
		      ReadProfile(RootFile, p, sDON, 0);
		    }
		  else
		    {
		      if (!strcasecmp(header,sprofileU2gtgDON))
			{

			  U2GTG++;

			  /* Reading the U2gtg donor profile */
			  p = gp->U2gtgDonorProfile;
			  ReadProfile(RootFile, p, sDON, 0);
			}
		      else
			{
		  	  if (!strcasecmp(header,sprofileU2gtyDON))
			    {

			      U2GTY++;

			      /* Reading the U2gty donor profile */
			      p = gp->U2gtyDonorProfile;
			      ReadProfile(RootFile, p, sDON, 0);
			    }
			  else
			    {		  
			      sprintf(mess,"Wrong format: profile name %s \n\tis not admitted for donors [only %s, %s, %s, %s, %s, %s or %s]",
				      header, sprofileDON, sprofileU12gtagDON, sprofileU12atacDON,sprofileU2gcagDON,sprofileU2gtaDON,sprofileU2gtgDON,sprofileU2gtyDON);
			      printError(mess);		
			    }
	  		}
		    }
		}
	    }
	}
      /* Next profile for donor site */
      readHeader(RootFile,line);
      if ((sscanf(line,"%s",header))!=1)
	{
	  sprintf(mess,"Wrong format: header in optional profile for donor sites");
	  printError(mess);
	}
    }

  /* Reading the Donor site profile */
  p = gp->DonorProfile;
  ReadProfile(RootFile, p, sDON, 0);
  
  /* Switch on the site prediction of U12gtag and U12atac introns */
  if (u12bp && u12gtagAcc && u12gtagDon){ U12GTAG++;SPLICECLASSES++;}
  if (u12bp && u12atacAcc && u12atacDon){ U12ATAC++;SPLICECLASSES++;}
  
}
Пример #6
0
/**
Read ICC, XMP, Exif, Exif-GPS, IPTC, descriptive (i.e. Exif-TIFF) metadata
@see ReadProfile, ReadDescriptiveMetadata
*/
static ERR
ReadMetadata(PKImageDecode *pID, FIBITMAP *dib) {
	ERR error_code = 0;		// error code as returned by the interface
	size_t currentPos = 0;	// current stream position
	
	WMPStream *pStream = pID->pStream;
	WmpDEMisc *wmiDEMisc = &pID->WMP.wmiDEMisc;
	BYTE *pbProfile = NULL;

	try {
		// save current position
		error_code = pStream->GetPos(pStream, &currentPos);
		JXR_CHECK(error_code);

		// ICC profile
		if(0 != wmiDEMisc->uColorProfileByteCount) {
			unsigned cbByteCount = wmiDEMisc->uColorProfileByteCount;
			unsigned uOffset = wmiDEMisc->uColorProfileOffset;
			error_code = ReadProfile(pStream, cbByteCount, uOffset, &pbProfile);
			JXR_CHECK(error_code);
			FreeImage_CreateICCProfile(dib, pbProfile, cbByteCount);
		}

		// XMP metadata
		if(0 != wmiDEMisc->uXMPMetadataByteCount) {
			unsigned cbByteCount = wmiDEMisc->uXMPMetadataByteCount;
			unsigned uOffset = wmiDEMisc->uXMPMetadataOffset;
			error_code = ReadProfile(pStream, cbByteCount, uOffset, &pbProfile);
			JXR_CHECK(error_code);
			// store the tag as XMP
			FITAG *tag = FreeImage_CreateTag();
			if(tag) {
				FreeImage_SetTagLength(tag, cbByteCount);
				FreeImage_SetTagCount(tag, cbByteCount);
				FreeImage_SetTagType(tag, FIDT_ASCII);
				FreeImage_SetTagValue(tag, pbProfile);
				FreeImage_SetTagKey(tag, g_TagLib_XMPFieldName);
				FreeImage_SetMetadata(FIMD_XMP, dib, FreeImage_GetTagKey(tag), tag);
				FreeImage_DeleteTag(tag);
			}
		}

		// IPTC metadata
		if(0 != wmiDEMisc->uIPTCNAAMetadataByteCount) {
			unsigned cbByteCount = wmiDEMisc->uIPTCNAAMetadataByteCount;
			unsigned uOffset = wmiDEMisc->uIPTCNAAMetadataOffset;
			error_code = ReadProfile(pStream, cbByteCount, uOffset, &pbProfile);
			JXR_CHECK(error_code);
			// decode the IPTC profile
			read_iptc_profile(dib, pbProfile, cbByteCount);
		}

		// Exif metadata
		if(0 != wmiDEMisc->uEXIFMetadataByteCount) {
			unsigned cbByteCount = wmiDEMisc->uEXIFMetadataByteCount;
			unsigned uOffset = wmiDEMisc->uEXIFMetadataOffset;
			error_code = ReadProfile(pStream, cbByteCount, uOffset, &pbProfile);
			JXR_CHECK(error_code);
			// decode the Exif profile
			jpegxr_read_exif_profile(dib, pbProfile, cbByteCount, uOffset);
		}

		// Exif-GPS metadata
		if(0 != wmiDEMisc->uGPSInfoMetadataByteCount) {
			unsigned cbByteCount = wmiDEMisc->uGPSInfoMetadataByteCount;
			unsigned uOffset = wmiDEMisc->uGPSInfoMetadataOffset;
			error_code = ReadProfile(pStream, cbByteCount, uOffset, &pbProfile);
			JXR_CHECK(error_code);
			// decode the Exif-GPS profile
			jpegxr_read_exif_gps_profile(dib, pbProfile, cbByteCount, uOffset);
		}

		// free profile buffer
		free(pbProfile);
		// restore initial position
		error_code = pID->pStream->SetPos(pID->pStream, currentPos);
		JXR_CHECK(error_code);

		// as a LAST STEP, read descriptive metadata
		// these metadata overwrite possible identical Exif-TIFF metadata 
		// that could have been read inside the Exif IFD
		
		return ReadDescriptiveMetadata(pID, dib);

	} catch(...) {
		// free profile buffer
		free(pbProfile);
		if(currentPos) {
			// restore initial position
			pStream->SetPos(pStream, currentPos);
		}
		return error_code;
	}
}