deps/kb_meme/meme-5.0.1/src/momo-input.c
/**
 * Parse a PSM header line. We want to locat the idx of filter_value, sequence, scan, and protein_id
 */
Parse a PSM header line. We want to locat the idx of filter_value, sequence, scan, and protein_id
Parse a PSM header line . We want to locat the idx of filter_value sequence scan and protein_id
void parse_tsv_header(MOMO_OPTIONS_T* options,
                      int* index_of_filter,
                      int* index_of_sequence,
                      int* index_of_scan,
                      int* index_of_protein,
                      FILE* fp, char** header,
                      size_t* len) {
  int i = 0;
  if (getline_nonempty(header, len, fp) != -1) {
    *header = strsep(header, "\n");	
    char *token;
    while((token = strsep(header, "\t")) != NULL) {
      while (isspace(*token)) token++;
      int t_end = strlen(token)-1;
      while (t_end >= 0 && isspace(token[t_end])) t_end--;
      char t_save = token[t_end+1];
      token[t_end+1] = '\0';
      if (strcmp(token, options->sequence_column) == 0) {
	*index_of_sequence = i;
      }
      if (options->filter && strcmp(token, options->filter_field) == 0) {
	*index_of_filter = i;
      }
      if (strcmp(token, "scan") == 0) {
	*index_of_scan = i;
      }
      if (strcmp(token, "protein id") == 0) {
	*index_of_protein = i;
      }
      token[t_end+1] = t_save;
      i++;
    }
  }
  if (*index_of_sequence == -1) {
    die("Could not find the modified peptide column named '%s' in the PSM file.", options->sequence_column);
  }
  if (options->filter && *index_of_filter == -1) {
    die("Could not find the filter column named '%s' in the PSM file.", options->filter_field);
  }
}
void parse_tsv_header ( MOMO_OPTIONS_T * options , int * index_of_filter , int * index_of_sequence , int * index_of_scan , int * index_of_protein , FILE * fp , char * * header , size_t * len ) { int i = 0 ; if ( getline_nonempty ( header , len , fp ) != -1 ) { * header = strsep ( header , " \n " ) ; char * token ; while ( ( token = strsep ( header , " \t " ) ) != NULL ) { while ( isspace ( * token ) ) token ++ ; int t_end = strlen ( token ) - 1 ; while ( t_end >= 0 && isspace ( token [ t_end ] ) ) t_end -- ; char t_save = token [ t_end + 1 ] ; token [ t_end + 1 ] = ' \0 ' ; if ( strcmp ( token , options -> sequence_column ) == 0 ) { * index_of_sequence = i ; } if ( options -> filter && strcmp ( token , options -> filter_field ) == 0 ) { * index_of_filter = i ; } if ( strcmp ( token , " " ) == 0 ) { * index_of_scan = i ; } if ( strcmp ( token , " " ) == 0 ) { * index_of_protein = i ; } token [ t_end + 1 ] = t_save ; i ++ ; } } if ( * index_of_sequence == -1 ) { die ( " " , options -> sequence_column ) ; } if ( options -> filter && * index_of_filter == -1 ) { die ( " " , options -> filter_field ) ; } }
Parse a PSM header line.
Parse a PSM header line .
// strip new line // Trim leading & trailing whitespace from token. // ensure that input file has required columns