Changes

From Genome Analysis Wiki
Jump to navigationJump to search
no edit summary
Line 49: Line 49:  
   SamValidationErrors samInvalidErrors;
 
   SamValidationErrors samInvalidErrors;
   −
  // Set writeStatus to success.  It will be changed
+
    // Set returnStatus to success.  It will be changed
  // to the failure reason if any of the writes fail.
+
    // to the failure reason if any of the writes fail.
  SamStatus::Status writeStatus = SamStatus::SUCCESS;
+
    SamStatus::Status returnStatus = SamStatus::SUCCESS;
   −
  // Keep reading records until ReadRecord returns false.
+
    // Keep reading records until ReadRecord returns false.
  while(samIn.ReadRecord(samHeader, samRecord))
+
    while(samIn.ReadRecord(samHeader, samRecord))
  {
+
    {
      // Successfully read a record from the file, so write it.
+
        // Successfully read a record from the file, so write it.
      if(!samOut.WriteRecord(samHeader, samRecord))
+
        if(!samOut.WriteRecord(samHeader, samRecord))
      {
+
        {
        // Failed to write a record.
+
            // Failed to write a record.
        fprintf(stderr, "%s\n", samOut.GetStatusMessage());
+
            fprintf(stderr, "%s\n", samOut.GetStatusMessage());
        writeStatus = samOut.GetStatus();
+
            returnStatus = samOut.GetStatus();
      }
+
        }
  }
+
    }
   −
  if(samIn.GetStatus() != SamStatus::NO_MORE_RECS)
+
    if(samIn.GetStatus() != SamStatus::NO_MORE_RECS)
  {
+
    {
      // Failed to read a record.
+
        // Failed to read a record.
      fprintf(stderr, "%s\n", samIn.GetStatusMessage());
+
        fprintf(stderr, "%s\n", samIn.GetStatusMessage());
  }
+
        // Set the return status to the reason why
 +
        // the read failed.
 +
        returnStatus = samIn.GetStatus();
 +
    }
   −
  std::cout << std::endl << "Number of records read = " <<  
+
    std::cout << std::endl << "Number of records read = " <<  
      samIn.GetCurrentRecordCount() << std::endl;
+
        samIn.GetCurrentRecordCount() << std::endl;
  std::cout << "Number of records written = " <<  
+
    std::cout << "Number of records written = " <<  
      samOut.GetCurrentRecordCount() << std::endl;
+
        samOut.GetCurrentRecordCount() << std::endl;
   −
  if(samIn.GetStatus() != SamStatus::NO_MORE_RECS)
+
    // Since the reads were successful, return the status based
  {
+
    // on the status of the writes.  If any failed, return
      // Failed reading a record.
+
    // their failure status.
      return(samIn.GetStatus());
+
    return(returnStatus);
  }
+
}
 
  −
  // Since the reads were successful, return the status based
  −
  // on the status of the writes.  If any failed, return
  −
  // their failure status.
  −
  return(writeStatus);
  −
}
   
</source>
 
</source>
  

Navigation menu