Exemplo n.º 1
0
GtMatchIterator* gt_match_iterator_open_new(const char *matchfile, GtError *err)
{
  GtMatchIterator *mp;
  GtMatchIteratorOpen *mpo;
  mp = gt_match_iterator_create(gt_match_iterator_open_class());
  mpo = (GtMatchIteratorOpen*) mp;
  mpo->pvt = gt_calloc(1, sizeof (GtMatchIteratorOpenMembers));
  GtFileMode mode;
  if (gt_file_exists(matchfile)) {
    mode = gt_file_mode_determine(matchfile);
    if (mode == GT_FILE_MODE_UNCOMPRESSED) {
      mpo->pvt->matchfilep = fopen(matchfile, "r");
      mpo->pvt->gtmatchfilep = NULL;
      if (!mpo->pvt->matchfilep) {
        gt_error_set(err, "Could not open %s", matchfile);
        return NULL;
      }
    } else {
      mpo->pvt->gtmatchfilep = gt_file_open(mode, matchfile, "r", err);
      mpo->pvt->matchfilep = NULL;
      if (!mpo->pvt->gtmatchfilep)
        return NULL;
    }
    mpo->pvt->matchfile = matchfile;
    return mp;
  } else {
    gt_error_set(err, "No such file or directory %s", matchfile);
    return NULL;
  }
}
Exemplo n.º 2
0
GtMatchIterator* gt_match_iterator_sw_new(GtEncseq *es1, GtEncseq *es2,
                                          GtScoreFunction *sf,
                                          unsigned long min_len,
                                          unsigned long max_edist,
                                          GT_UNUSED GtError *err)
{
  GtMatchIterator *mi;
  GtMatchIteratorSW *mis;
  gt_assert(es1 && es2 && sf);
  gt_error_check(err);

  mi = gt_match_iterator_create(gt_match_iterator_sw_class());
  mis = (GtMatchIteratorSW*) mi;
  mis->pvt = gt_calloc(1, sizeof (GtMatchIteratorSWMembers));
  mis->pvt->es1 = gt_encseq_ref(es1);
  mis->pvt->es2 = gt_encseq_ref(es2);
  mis->pvt->sf = gt_score_function_ref(sf);
  mis->pvt->min_len = min_len;
  mis->pvt->max_edist = max_edist;
  mis->pvt->firstali = true;
  return mi;
}