Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readAl / trimAl creates an empty file when trying to output a non-aligned format/alignment to an aligned-format. #34

Open
Vicfero opened this issue Aug 4, 2017 · 1 comment

Comments

@Vicfero
Copy link
Contributor

Vicfero commented Aug 4, 2017

Both programs output an empty file when given a non-aligned file / alignment (ex: dataset/example.007.AA.only_seqs) and asked to save in a alignment-format (clustal, phylip, etc)

The program warns about this problem, but the check is done in functions 'alignmentXToFile' when the file has been created.
The problem seems to be on function "alignment::saveAlignment(char *destFile)" on "alignment.cpp", line 607-673:

bool alignment::saveAlignment(char *destFile) {

  ofstream file;

  if(sequences == NULL)
    return false;

  if((residNumber == 0)  || (sequenNumber == 0)) {
    cerr << endl << "WARNING: Output alignment has not been generated. "
      << "It is empty." << endl << endl;
    return true;
  }

  /* File open and correct open check */
  file.open(destFile);
  if(!file) return false;

  /* Depending on the output format, we call to the appropiate function */
  switch(oformat) {
    case 1:
      alignmentClustalToFile(file);
      break;
    case 3:
      alignmentNBRF_PirToFile(file);
      break;
    case 8:
      alignmentFastaToFile(file);
      break;
    case 11:
      alignmentPhylip3_2ToFile(file);
      break;
    case 12:
      alignmentPhylipToFile(file);
      break;
    case 13:
      alignmentPhylip_PamlToFile(file);
      break;
    case 17:
      alignmentNexusToFile(file);
      break;
    case 21: case 22:
      alignmentMegaToFile(file);
      break;
    case 99:
      getSequences(file);
      break;
    case 100:
      alignmentColourHTML(file);
      break;
    default:
      return false;
  }

  /* Close the output file */
  file.close();

  /* All is OK, return true */
  return true;
}

The warning of this problem:

ERROR: Sequences are not aligned. Format (X) not compatible with unaligned sequences.

Is done after opening the ofstream, thus, making an empty file.

@Vicfero Vicfero changed the title readAl / trimAl creates an empty file when trying to output a non-aligned format to an aligned-format. readAl / trimAl creates an empty file when trying to output a non-aligned format/alignment to an aligned-format. Aug 4, 2017
@scapella
Copy link
Collaborator

Please, @Vicfero check which formats require sequences to be aligned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants