コード例 #1
0
ファイル: sscawrd.c プロジェクト: fbtestrepo/hw
extern void ArchiveBadgesDialog (
  DialoG d,
  FILE *fp
)

{
  IntBadgPtr  ibp;
  Int2        k, n, numItems;
  SscBadgPtr  sbp;

  sbp = (SscBadgPtr) GetObjectExtra (d);
  if (sbp == NULL || fp == NULL) return;

  GetDocParams (sbp->badglog, &numItems, NULL);
  for (k = 1, n = 0; k <= numItems; k++) {
    ibp = GetBadgInfo (sbp, k);
    if (ibp == NULL) continue;
    if (StringHasNoText (ibp->name)) continue;
    n++;
  }
  if (n < 1) return;

  fprintf (fp, "AWARDS -----\n\n%s\n\n", archiveBadgLabel);

  for (k = 1; k <= numItems; k++) {
    ibp = GetBadgInfo (sbp, k);
    if (ibp == NULL) continue;
    if (StringHasNoText (ibp->name)) continue;
    SaveDocumentItem (sbp->badglog, fp, k);
  }
  fprintf (fp, "\n");
}
コード例 #2
0
ファイル: tbl_chk.c プロジェクト: hsptools/hsp-wrap
static void PrintMisMatches(FILE *out, CharPtr id_txt, ValNodePtr val, ValNodePtr col, ValNodePtr field)
{
  CharPtr label = NULL;

  while (field != NULL && (val != NULL || col != NULL)) {
    if (val == NULL) {
      if (!StringHasNoText (col->data.ptrvalue)) {
        label = SummarizeFieldType (field);
        fprintf (out, "%s\t%s\t\t%s\n", id_txt, label, (char *) col->data.ptrvalue);
      }
    } else if (col == NULL) {
      if (!StringHasNoText (val->data.ptrvalue)) {
        label = SummarizeFieldType (field);
        fprintf (out, "%s\t%s\t%s\t\n", id_txt, label, (char *) val->data.ptrvalue);
      }
    } else if (!StringHasNoText (val->data.ptrvalue) && !StringHasNoText (col->data.ptrvalue)
               && StringCmp (val->data.ptrvalue, col->data.ptrvalue) != 0) {
      label = SummarizeFieldType (field);
      fprintf (out, "%s\t%s\t%s\t%s\n", id_txt, label, (char *) val->data.ptrvalue, (char *) col->data.ptrvalue);
    }
    label = MemFree (label);

    if (val != NULL) {
      val = val->next;
    }
    if (col != NULL) {
      col = col->next;
    }
    field = field->next;
  }
}
コード例 #3
0
ファイル: idcleanscan.c プロジェクト: hsptools/hsp-wrap
static void RecordThesis (ScanDataPtr sdp, CharPtr str)

{
  StringSetPtr  ssp;
  ValNodePtr    vnp;

  if (sdp == NULL || StringHasNoText (str)) return;

  for (vnp = sdp->lcList; vnp != NULL; vnp = vnp->next) {
    ssp = (StringSetPtr) vnp->data.ptrvalue;
    if (ssp == NULL) continue;
    if (StringCmp (ssp->text, str) == 0) {
      (ssp->count)++;
      return;
    }
  }

  ssp = MemNew (sizeof (StringSet));
  if (ssp == NULL) return;
  StringCpy (ssp->firstID, sdp->buf);
  StringNCpy_0 (ssp->text, str, sizeof (ssp->text));
  ssp->count = 1;

  ValNodeAddPointer (&(sdp->lcList), 0, (Pointer) ssp);
}
コード例 #4
0
ファイル: tbl_chk.c プロジェクト: hsptools/hsp-wrap
static SeqIdPtr SmartGuessMakeId (CharPtr str)
{
  CharPtr id_txt;
  SeqIdPtr sip = NULL;

  if (StringHasNoText (str)) {
    return NULL;
  } else if (StringChr (str, '|') != NULL) {
    sip = MakeSeqID (str);
  } else if (IsAllDigits (str)) {
    id_txt = (CharPtr) MemNew (sizeof (Char) * (StringLen (str) + 4));
    sprintf (id_txt, "gi|%s", str);
    sip = MakeSeqID (id_txt);
    id_txt = MemFree (id_txt);
  } else if (StringChr (str, '_') != NULL) {
    id_txt = (CharPtr) MemNew (sizeof (Char) * (StringLen (str) + 5));
    sprintf (id_txt, "oth|%s", str);
    sip = MakeSeqID (id_txt);
    id_txt = MemFree (id_txt);
  } else {
    id_txt = (CharPtr) MemNew (sizeof (Char) * (StringLen (str) + 4));
    sprintf (id_txt, "gb|%s", str);
    sip = MakeSeqID (id_txt);
    id_txt = MemFree (id_txt);
  }
  return sip;
}
コード例 #5
0
ファイル: sscawrd.c プロジェクト: fbtestrepo/hw
extern void ExportBadgesDialog (
  DialoG d,
  ValNodePtr PNTR head
)

{
  Char        buf [128], tmp [32];
  DoC         doc;
  IntBadgPtr  ibp;
  Int2        k, numItems;
  SscBadgPtr  sbp;

  sbp = (SscBadgPtr) GetObjectExtra (d);
  if (sbp == NULL || head == NULL) return;

  doc = sbp->badglog;
  GetDocParams (doc, &numItems, NULL);
  for (k = 1; k <= numItems; k++) {
    ibp = GetBadgInfo (sbp, k);
    if (ibp == NULL) continue;
    if (StringHasNoText (ibp->name)) continue;
    buf [0] = '\0';
    ExportDocCell (doc, k, 1, buf);
    TabToCol (buf, 22);
    ExportDocCell (doc, k, 3, tmp);
    StringCat (buf, tmp);
    ValNodeCopyStr (head, k + 100, buf);
  }
}
コード例 #6
0
ファイル: vsmfile.c プロジェクト: hsptools/hsp-wrap
static void ExciseProteinIDLine (CharPtr line)
{
  CharPtr protein_id_line_start = NULL, protein_id_line_end;
  
  if (StringHasNoText (line))
  {
    return;
  }
  
  protein_id_line_start = StringStr (line, "\n\t\t\tprotein_id\t");
  if (protein_id_line_start == NULL)
  {
    return;
  }
  protein_id_line_end = StringChr (protein_id_line_start + 1, '\n');
  if (protein_id_line_end == NULL)
  {
    return;
  }
  
  while (*protein_id_line_end != 0)
  {
    *protein_id_line_start = *protein_id_line_end;
    protein_id_line_start ++;
    protein_id_line_end ++;
  }
  *protein_id_line_start = 0;
}
コード例 #7
0
NLM_EXTERN Int4 VecScreenCheckQueue (
  VQUEUE* queue
)

{
  CONN            conn;
  Nlm_Int4        count = 0;
  VQueuePtr       curr;
  time_t          currtime;
  VQueuePtr       next;
  VQueuePtr PNTR  qptr;
  Char            str [128];

  qptr = (VQueuePtr PNTR) queue;
  if (qptr == NULL || *qptr == NULL) return 0;

  curr = *qptr;

  while (curr != NULL) {
    next = curr->next;

    /* check for return of rID, WAITING, of SUCCESS message */

    QUERY_CheckQueue (&(curr->connqueue));

    if (curr->done) {
      VecScreen_RemoveFromQueue (queue, curr);

    } else {
      if (curr->connqueue == NULL) {
        currtime = GetSecs ();
        if (currtime - curr->postedTime < curr->secondsToWait) {
        } else if (! StringHasNoText (curr->rid)) {

          /* estimated wait time has expired, so queue another check */

          if (curr->secondsToWait < 300) {
            curr->secondsToWait *= 2;
            if (curr->secondsToWait > 300) {
              curr->secondsToWait = 300;
            }
          }
          curr->postedTime = GetSecs ();

          sprintf (str, "req=%s", curr->rid);
          conn = VecScreenOpenConnection (str);
          QUERY_SendQuery (conn);
          QUERY_AddToQueue (&(curr->connqueue), conn, SecondVecScreenCallback, (Pointer) curr, TRUE);
        }
      }

      count++;
    }

    curr = next;
  }

  return count;
}
コード例 #8
0
ファイル: netcnfg.c プロジェクト: hsptools/hsp-wrap
static Boolean NoEntryExists (CharPtr sect, CharPtr type)

{
  Char  str [256];

  if (GetAppParam ("NCBI", sect, type, NULL, str, sizeof (str))) {
    if (! StringHasNoText (str)) return FALSE;
  }
  return TRUE;
}
コード例 #9
0
ファイル: tbl_chk.c プロジェクト: hsptools/hsp-wrap
static Boolean HasMismatch
(ValNodePtr values,
 ValNodePtr col)
{
  Boolean rval = FALSE;

  while (!rval && values != NULL && col != NULL) {
    if (StringHasNoText (values->data.ptrvalue)
        && StringHasNoText (col->data.ptrvalue)) {
      /* both empty, ignore */
    } else if (StringCmp (values->data.ptrvalue, col->data.ptrvalue)) {
      rval = TRUE;
    }
    values = values->next;
    col = col->next;
  }
  if (values != NULL || col != NULL) {
    rval = TRUE;
  }
  return rval;
}
コード例 #10
0
ファイル: idcleanscan.c プロジェクト: hsptools/hsp-wrap
static void DoTitle (SeqDescrPtr vnp, Pointer userdata)

{
  Char         ch;
  CharPtr      ptr, str, tmp;
  ScanDataPtr  sdp;

  if (vnp->choice != Seq_descr_title) return;
  str = (CharPtr) vnp->data.ptrvalue;
  if (StringHasNoText (str)) return;

  sdp = (ScanDataPtr) userdata;

  tmp = str;
  ptr = StringStr (tmp, "complete ");
  while (ptr != NULL) {
    tmp = ptr + 9;
    ch = *tmp;
    while (ch != '\0' && (! (IS_WHITESP (ch)))) {
      tmp++;
      ch = *tmp;
    }
    if (ch == '\0') return;
    if (StringNICmp (tmp, " genome", 7) == 0) {
      tmp [7] = '\0';
      RecordTitle (sdp, ptr);
      return;
    } else if (StringNICmp (tmp, " DNA", 4) == 0) {
      tmp [4] = '\0';
      RecordTitle (sdp, ptr);
      return;
    } else if (StringNICmp (tmp, " sequence", 9) == 0) {
      tmp [9] = '\0';
      RecordTitle (sdp, ptr);
      return;
    }
    ptr = StringStr (tmp, "complete ");
  }

  if (StringStr (str, "genome DNA") != NULL) {
    RecordTitle (sdp, "genome DNA");
    return;
  }

  if (sdp->bulk) return;

  if (StringStr (str, "genomic DNA") != NULL) {
    RecordTitle (sdp, "genomic DNA");
    return;
  }
}
コード例 #11
0
ファイル: vsmfile.c プロジェクト: hsptools/hsp-wrap
static Boolean SaveSetsInOneSelectedSet (GatherObjectPtr gop)

{
  SetSavePtr      ssp;
  SelStructPtr    sel;
  BioseqSetPtr    bssp;
  CharPtr         filename, file_fmt = "%s_%d.sqn";
  SeqEntryPtr     sep;
  AsnIoPtr        aip;
#ifdef WIN_MAC
  FILE *fp;
#endif

  if (gop == NULL || gop->dataptr == NULL || gop->itemtype != OBJ_BIOSEQSET) return TRUE;
  ssp = (SetSavePtr) gop->userdata;
  if (ssp == NULL || StringHasNoText (ssp->file_base)) return TRUE;

  sel = ssp->sel;
  while (sel != NULL 
         && (sel->entityID != gop->entityID 
             || sel->itemtype != gop->itemtype 
             || sel->itemID != gop->itemID))
  {
    sel = sel->next;
  }

  if (sel == NULL) return TRUE;

  bssp = gop->dataptr;
   
  filename = (CharPtr) MemNew (sizeof (Char) + (StringLen (ssp->file_base) + StringLen (file_fmt) + 15));
  for (sep = bssp->seq_set; sep != NULL; sep = sep->next) {
    sprintf (filename, file_fmt, ssp->file_base, ssp->file_num);
    ssp->file_num++;
#ifdef WIN_MAC
        fp = FileOpen (filename, "r");
        if (fp != NULL) {
            FileClose (fp);
        } else {
            FileCreate (filename, "TEXT", "ttxt");
        }
#endif

        aip = AsnIoOpen(filename, "w");
        SeqEntryAsnWrite (sep, aip, NULL);
    AsnIoClose (aip);
  }
  filename = MemFree (filename);
  return TRUE;
}
コード例 #12
0
ファイル: tbl_chk.c プロジェクト: hsptools/hsp-wrap
extern Pointer ReadFromTPASmart (CharPtr accn, Uint2Ptr datatype, Uint2Ptr entityID)

{
  Char     cmmd [256];
  Pointer  dataptr;
  FILE*    fp;
  Char     path [PATH_MAX];
  Char     err_path [PATH_MAX];

  if (datatype != NULL) {
    *datatype = 0;
  }
  if (entityID != NULL) {
    *entityID = 0;
  }
  if (StringHasNoText (accn)) return NULL;

  if (tpasmartfetchcmd == NULL) {
    if (GetAppParam ("SEQUIN", "TPASMART", "FETCHSCRIPT", NULL, cmmd, sizeof (cmmd))) {
    	tpasmartfetchcmd = StringSaveNoNull (cmmd);
    }
  }
  if (tpasmartfetchcmd == NULL) return NULL;

  TmpNam (path);

#ifdef OS_UNIX
  sprintf (err_path, "%s.err", path);
  sprintf (cmmd, "csh %s %s > %s 2>%s", tpasmartfetchcmd, accn, path, err_path);
  system (cmmd);
#endif
#ifdef OS_MSWIN
  sprintf (cmmd, "%s %s -o %s", tpasmartfetchcmd, accn, path);
  system (cmmd);
#endif

  fp = FileOpen (path, "r");
  if (fp == NULL) {
    FileRemove (path);
    return NULL;
  }
  dataptr = ReadAsnFastaOrFlatFile (fp, datatype, entityID, FALSE, FALSE, TRUE, FALSE);
  FileClose (fp);
  FileRemove (path);
#ifdef OS_UNIX
  FileRemove (err_path);
#endif
  return dataptr;
}
コード例 #13
0
ファイル: urlquery.c プロジェクト: hsptools/hsp-wrap
/* Set HTTP user header */
static void x_SetupUserHeader (
  SConnNetInfo*  net_info,
  const char*    appName,
  EMIME_Type     type,
  EMIME_SubType  subtype,
  EMIME_Encoding encoding
)
{
  const char* userAgentName = NULL;
  char        user_header [MAX_CONTENT_TYPE_LEN + 80];

  /* content-type if specified */
  if (type < eMIME_T_Unknown) {
    VERIFY( MIME_ComposeContentTypeEx (type, subtype, encoding,
                                       user_header, MAX_CONTENT_TYPE_LEN) );
    ConnNetInfo_OverrideUserHeader (net_info, user_header);
  }

  /* allow the user to specify a prog. name, otherwise get it from elsewhere */
  if (StringHasNoText (appName)) {
    const char* progName = GetProgramName();
    if (StringHasNoText (progName)) {
      char path [PATH_MAX];
      Nlm_ProgramPath (path, sizeof (path));
      userAgentName = StringRChr (path, DIRDELIMCHR);
      if (userAgentName)
        ++userAgentName;
    } else
      userAgentName = progName;
  } else
    userAgentName = appName;
  if (StringDoesHaveText (userAgentName)) {
    sprintf (user_header, "User-Agent: %.80s\r\n", userAgentName);
    ConnNetInfo_ExtendUserHeader (net_info, user_header);
  }
}
コード例 #14
0
ファイル: dotmain.c プロジェクト: hsptools/hsp-wrap
static void DOT_AcceptNetworkProc(ButtoN b)
{
  DOTStartDataPtr sdata;
  WindoW          w;
  Char            str1[50]={""}, str2[50]={""};
  BioseqPtr       qbsp=NULL, sbsp=NULL;
  SeqEntryPtr     qsep, ssep;
  Uint2           entityID1, entityID2;
  Int2            rtn=0;
  DOTMainDataPtr  mip;
  SeqLocPtr       slp1=NULL, slp2=NULL;

  w=ParentWindow(b);  
  Hide(w);
  sdata=(DOTStartDataPtr)GetObjectExtra(w);
  GetTitle(sdata->id1, str1, sizeof(str1));
  GetTitle(sdata->id2, str2, sizeof(str2));
  if (StringHasNoText (str1) || StringHasNoText(str2)) {
    Message (MSG_ERROR, "enter GI or Accession number");
    Show (w);
    Select (w);
    Select (sdata->id1);
    return;
  }

  qbsp = DOT_FetchBioseqGivenString(str1, &rtn);
  sbsp = DOT_FetchBioseqGivenString(str2, &rtn);

  if (rtn <0 || !qbsp || !sbsp){
    DOT_RespondtoFetch(rtn, w, sdata);
    return;
  }
  
  DOT_RunRequest(w, qbsp, sbsp, sdata);
  
}
コード例 #15
0
ファイル: idcleanscan.c プロジェクト: hsptools/hsp-wrap
static void PrintGraphMessage (BioseqPtr bsp, ScanDataPtr sdp,
                               CharPtr prefix, CharPtr suffix)

{
  Char  buf [41];

  if (bsp == NULL || sdp == NULL || prefix == NULL) return;

  SeqIdWrite (bsp->id, buf, PRINTID_FASTA_LONG, sizeof (buf));
  fprintf (sdp->fp, "QA - %s - %s", buf, prefix);
  if (! StringHasNoText (suffix)) {
    fprintf (sdp->fp, " - %s", suffix);
  }
  fprintf (sdp->fp, "\n");
}
コード例 #16
0
ファイル: acerdapi.c プロジェクト: fast-project/mpifast
static Boolean UpdateContigReadId (TContigReadPtr read, SeqIdReplaceListPtr pair_list, Boolean no_lookup, Boolean is_srr, char *has_errors)
{
  SeqIdPairPtr pair;
  SeqIdPtr     sip_find;
  Char         id_buf[255];
  Boolean      rval = TRUE;

  if (read == NULL || StringHasNoText (read->read_id)) {
    rval = FALSE;
  } else {
    sip_find = MakeSeqID (read->read_id);
    pair = FindReplacementInSeqIdReplaceList (sip_find, pair_list);
    if (pair != NULL && (no_lookup || OkToReplaceId (pair, read->read_seq, has_errors))) {
      if (pair->is_complement) {
        if (read->is_complement) {
          read->is_complement = FALSE;
        } else {
          read->is_complement = TRUE;
        }
      }
      if (pair->ti > 0) {
        read->ti = pair->ti;
      } else {
        if (pair->sip_replace->choice == SEQID_LOCAL) {
          SeqIdWrite (pair->sip_replace, id_buf, PRINTID_REPORT, sizeof (id_buf) - 1);
        } else {
          SeqIdWrite (pair->sip_replace, id_buf, PRINTID_FASTA_LONG, sizeof (id_buf) - 1);
        }
        if (is_srr) {
          if (read->srr != NULL) {
            free (read->srr);
          }
          read->srr = malloc (sizeof (Char) * (StringLen (id_buf) + 1));
          sprintf (read->srr, "%s", id_buf);
          free (read->read_id);
          read->read_id = NULL;
        } else {
          free (read->read_id);
          read->read_id = malloc (sizeof (Char) * (StringLen (id_buf) + 1));
          sprintf (read->read_id, "%s", id_buf);
        }
      }
      read->local = FALSE;
    }
    sip_find = SeqIdFree (sip_find);
  }
  return rval;
}
コード例 #17
0
ファイル: tbl_chk.c プロジェクト: hsptools/hsp-wrap
static Boolean IsAllDigits (CharPtr str)
{
  CharPtr cp;

  if (StringHasNoText (str)) return FALSE;

  cp = str;
  while (*cp != 0 && isdigit (*cp)) {
    cp++;
  }
  if (*cp == 0) {
    return TRUE;
  } else {
    return FALSE;
  }
}
コード例 #18
0
ファイル: cspeedtest.c プロジェクト: jbreitbart/mpifast
static void ProcessOneRecord (
  CharPtr filename,
  Pointer userdata
)

{
  CSpeedFlagPtr  cfp;

  if (StringHasNoText (filename)) return;
  cfp = (CSpeedFlagPtr) userdata;
  if (cfp == NULL) return;

  if (cfp->batch) {
    ProcessMultipleRecord (filename, cfp);
  } else {
    ProcessSingleRecord (filename, cfp);
  }
}
コード例 #19
0
ファイル: sscawrd.c プロジェクト: fbtestrepo/hw
static Pointer AdjPageToAwardDataPtr(DialoG d)

{
  AwardDataPtr  badges, bdp, lastbdp;
  IntBadgPtr    ibp;
  Int2          k, numItems;
  SscBadgPtr    sbp;
  SscTablesPtr  stp;

  sbp = (SscBadgPtr) GetObjectExtra (d);
  if (sbp == NULL) return NULL;
  stp = sbp->tables;
  if (stp == NULL) return NULL;

  badges = NULL;

  lastbdp = NULL;
  GetDocParams (sbp->badglog, &numItems, NULL);
  for (k = 1; k <= numItems; k++) {
    ibp = GetBadgInfo (sbp, k);
    if (ibp == NULL) continue;
    if (StringHasNoText (ibp->name)) continue;
    bdp = AwardDataNew ();
    if (bdp == NULL) continue;

    bdp->name = StringSaveNotEmpty (ibp->name);
    bdp->type = ibp->type;
    bdp->comment = StringSaveNotEmpty (ibp->comment);

    bdp->reason = ibp->reason;

    if (badges == NULL) {
      badges = bdp;
    }
    if (lastbdp != NULL) {
      lastbdp->next = bdp;
    }
    lastbdp = bdp;
  }

  return (Pointer) badges;
}
コード例 #20
0
NLM_EXTERN Boolean VecScreenAsynchronousRequest (
  CharPtr database,
  BioseqPtr bsp,
  VQUEUE* queue,
  VecScreenResultProc resultproc,
  VecScreenAnnounceProc announceproc,
  VoidPtr userdata
)

{
  CONN  conn;
  FILE  *fp;
  Char  path [PATH_MAX];
  Char  str [128];

  if (bsp == NULL || queue == NULL || resultproc == NULL) return FALSE;

  if (StringHasNoText (database)) {
    database = "UniVec";
  }
  sprintf (str, "db=%s", database);
  conn = VecScreenOpenConnection (str);
  if (conn == NULL) return FALSE;

  TmpNam (path);

  fp = FileOpen (path, "w");
  BioseqToFasta (bsp, fp, ISA_na (bsp->mol));
  FileClose (fp);

  fp = FileOpen (path, "r");
  QUERY_CopyFileToQuery (conn, fp);
  FileClose (fp);

  QUERY_SendQuery (conn);

  VecScreen_AddToQueue (queue, resultproc, announceproc, userdata, conn, bsp);

  FileRemove (path);

  return TRUE;
}
コード例 #21
0
ファイル: tbl_chk.c プロジェクト: hsptools/hsp-wrap
static ValNodePtr FieldsFromFieldListString (CharPtr str)
{
  CharPtr cpy, val, comma;
  Int4    qual;
  ValNodePtr field_list = NULL, qc;

  if (StringHasNoText (str)) {
    return NULL;
  }
  cpy = StringSave (str);
  val = cpy;
  comma = StringChr(val, ',');
  while (comma != NULL) {
    *comma = 0;
    qual = GetSourceQualTypeByName(val);
    if (qual < 0) {
      Message (MSG_ERROR, "%s is not a recognized source field name", val);
    } else {
      qc = ValNodeNew (NULL);
      qc->choice = SourceQualChoice_textqual;
      qc->data.intvalue = qual;
      ValNodeAddPointer (&field_list, FieldType_source_qual, qc);
    }
    *comma = ',';
    val = comma + 1;
    comma = StringChr (val, ',');
  }

  qual = GetSourceQualTypeByName(val);
  if (qual < 0) {
    Message (MSG_ERROR, "%s is not a recognized source field name", val);
  } else {
    qc = ValNodeNew (NULL);
    qc->choice = SourceQualChoice_textqual;
    qc->data.intvalue = qual;
    ValNodeAddPointer (&field_list, FieldType_source_qual, qc);
  }

  cpy = MemFree (cpy);
  return field_list;
}
コード例 #22
0
ファイル: cspeedtest.c プロジェクト: jbreitbart/mpifast
static void DoNewFastaDefline (
  BioseqPtr bsp,
  Pointer userdata
)

{
  BioseqSetPtr   bssp;
  CSpeedFlagPtr  cfp;
  Char           id [128];
  CharPtr        title;

  if (bsp == NULL) return;
  cfp = (CSpeedFlagPtr) userdata;
  if (cfp == NULL) return;

  if (StringChr (cfp->skip, 's') != NULL) {
    if (bsp->idx.parenttype == OBJ_BIOSEQSET) {
      bssp = (BioseqSetPtr) bsp->idx.parentptr;
      if (bssp != NULL) {
        if (bssp->_class == BioseqseqSet_class_segset ||
            bssp->_class == BioseqseqSet_class_parts) return;
      }
    }
  }
  if (StringChr (cfp->skip, 'v') != NULL) {
    if (bsp->repr == Seq_repr_virtual) return;
  }

  id [0] = '\0';
  SeqIdWrite (bsp->id, id, PRINTID_FASTA_LONG, sizeof (id) - 1);
  title = NewCreateDefLine (NULL, bsp, FALSE, FALSE);
  if (StringHasNoText (title)) {
    title = StringSave ("?");
  }

  if (cfp->ofp != NULL) {
    fprintf (cfp->ofp, ">%s %s\n", id, title);
  }

  MemFree (title);
}
コード例 #23
0
ファイル: idcleanscan.c プロジェクト: hsptools/hsp-wrap
static void PrintFeatureMessage (SeqFeatPtr sfp, ScanDataPtr sdp,
                                 CharPtr prefix, CharPtr suffix)

{
  BioseqPtr  bsp;
  Char       buf [41];

  if (sfp == NULL || sdp == NULL || prefix == NULL) return;

  bsp = BioseqFindFromSeqLoc (sfp->location);
  if (bsp != NULL) {
    SeqIdWrite (bsp->id, buf, PRINTID_FASTA_LONG, sizeof (buf));
    fprintf (sdp->fp, "%s - %s", prefix, buf);
  } else {
    fprintf (sdp->fp, "%s - %s", prefix, sdp->buf);
  }
  if (! StringHasNoText (suffix)) {
    fprintf (sdp->fp, " - %s", suffix);
  }
  fprintf (sdp->fp, "\n");
}
コード例 #24
0
ファイル: acerdapi.c プロジェクト: fast-project/mpifast
static Boolean OkToReplaceId (SeqIdPairPtr pair, CharPtr seq_str, char *has_errors)
{
  Boolean rval = FALSE;
  SeqEntryPtr fetched_sep, old_scope;
  BioseqPtr   bsp_replace;

  if (StringHasNoText (seq_str)) {
    rval = FALSE;
  }

  if (pair == NULL || pair->sip_replace == NULL) {
    rval = FALSE;
  } else if ((fetched_sep = FetchRead (pair->sip_replace)) == NULL) {
    rval = FALSE;
    ReportInvalidReplacement (pair->sip_replace, "Unable to fetch far sequence", has_errors);
  } else {
    old_scope = SeqEntrySetScope (fetched_sep);
    bsp_replace = BioseqFind (pair->sip_replace);
    SeqEntrySetScope (old_scope);
    if (bsp_replace == NULL) {
      rval = FALSE;
      ReportInvalidReplacement (pair->sip_replace, "Unable to locate far sequence after fetch", has_errors);
    } else if (DoesSeqStringMatchBsp (seq_str, bsp_replace, Seq_strand_plus)) {
      /* matches */
      rval = TRUE;
      pair->ti = GetTraceIDFromIdList (bsp_replace->id);
    } else if (DoesSeqStringMatchBsp (seq_str, bsp_replace, Seq_strand_minus)) {
      /* matches on complement */
      pair->is_complement = TRUE;
      rval = TRUE;
      pair->ti = GetTraceIDFromIdList (bsp_replace->id);
    } else {
      /* later, are we going to try to find trim lengths? */
      rval = FALSE;
      ReportInvalidReplacement (pair->sip_replace, "Replacement does not match local", has_errors);
    }
    SeqEntryFree (fetched_sep);
  }
  return rval;
}
コード例 #25
0
ファイル: idcleanscan.c プロジェクト: hsptools/hsp-wrap
static void DoThesis (PubdescPtr pdp, Pointer userdata)

{
  CitBookPtr   cbp;
  Char         ch;
  ScanDataPtr  sdp;
  CharPtr      title, tmp;
  ValNodePtr   ttl, vnp;

  if (pdp == NULL) return;

  for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) {
    if (vnp->choice == PUB_Man) {
      cbp = (CitBookPtr) vnp->data.ptrvalue;
      if (cbp != NULL) {
        ttl = cbp->title;
        if (ttl != NULL) {
          title = (CharPtr) ttl->data.ptrvalue;
          if (! StringHasNoText (title)) {
            if (StringLen (title) > 3) {
              ch = *title;
              if (IS_LOWER (ch)) {
                tmp = title;
                ch = *tmp;
                while (ch != '\0' && (! (IS_WHITESP (ch)))) {
                  tmp++;
                  ch = *tmp;
                }
                *tmp = '\0';
                sdp = (ScanDataPtr) userdata;
                RecordThesis (sdp, title);
              }
            }
          }
        }
      }
    }
  }
}
コード例 #26
0
ファイル: valdlg.c プロジェクト: hsptools/hsp-wrap
static FieldRulePtr FieldRuleFromTagString (CharPtr str)
{
  FieldRulePtr rule;
  CharPtr tmp;

  if (StringHasNoText (str)) {
    return NULL;
  }

  rule = FieldRuleNew ();
  rule->field_name = ExtractTagListColumn (str, COMMENTRULEEDIT_FIELDNAME_COLUMN);
  rule->match_expression = ExtractTagListColumn (str, COMMENTRULEEDIT_MATCH_COLUMN);
  tmp = ExtractTagListColumn (str, COMMENTRULEEDIT_REQUIRED_COLUMN);
  if (tmp != NULL && atoi (tmp) > 0) {
    rule->required = TRUE;
  } else {
    rule->required = FALSE;
  }
  tmp = MemFree (tmp);

  return rule;
}
コード例 #27
0
ファイル: cspeedtest.c プロジェクト: jbreitbart/mpifast
static void DoFastaComp (
  BioseqPtr bsp,
  Pointer userdata,
  Boolean ignoreExisting
)

{
  Char           buf [4096];
  CSpeedFlagPtr  cfp;
  Char           id [128];
  CharPtr        title;

  if (bsp == NULL) return;
  cfp = (CSpeedFlagPtr) userdata;
  if (cfp == NULL) return;

  id [0] = '\0';
  SeqIdWrite (bsp->id, id, PRINTID_FASTA_LONG, sizeof (id) - 1);
  buf [0] = '\0';
  CreateDefLineExEx (NULL, bsp, buf, sizeof (buf) - 1, 0,
                     NULL, NULL, ignoreExisting, FALSE);
  title = NewCreateDefLine (NULL, bsp, ignoreExisting, FALSE);
  if (StringHasNoText (title)) {
    title = StringSave ("?");
  }

  if (StringCmp (buf, title) != 0) {
    if (cfp->ofp != NULL) {
      fprintf (cfp->ofp, "<  %s %s\n", id, buf);
      fprintf (cfp->ofp, ">  %s %s\n", id, title);
    }
    printf ("<  %s %s\n", id, buf);
    printf (">  %s %s\n", id, title);
    fflush (stdout);
  }

  MemFree (title);
}
コード例 #28
0
ファイル: acerdapi.c プロジェクト: fast-project/mpifast
static Boolean ValidateContigReadId (TContigReadPtr read, char *has_errors)
{
  SeqIdPairData pair;
  Char          id_buf[255];
  Boolean       rval = TRUE;

  if (read == NULL || StringHasNoText (read->read_id)) {
    rval = FALSE;
  } else if (!read->local) {
    rval = TRUE;
  } else {
    pair.sip_find = NULL;
    pair.is_complement = FALSE;
    pair.is_consensus = FALSE;
    pair.trim3 = 0;
    pair.trim5 = 0;
    pair.sip_replace = MakeSeqID (read->read_id);
    pair.ti = 0;
    if (OkToReplaceId (&pair, read->read_seq, has_errors)) {
      if (pair.is_complement && !read->is_complement) {
        read->is_complement = TRUE;
      } else if (!pair.is_complement && read->is_complement) {
        read->is_complement = FALSE;
      }
      if (pair.ti > 0) {
        read->ti = pair.ti;
      } else {
        SeqIdWrite (pair.sip_replace, id_buf, PRINTID_FASTA_LONG, sizeof (id_buf) - 1);
        free (read->read_id);
        read->read_id = malloc (sizeof (Char) * (StringLen (id_buf) + 1));
        sprintf (read->read_id, "%s", id_buf);
      }
      read->local = FALSE;
    }
    pair.sip_replace = SeqIdFree (pair.sip_replace);
  }
  return rval;
}
コード例 #29
0
ファイル: sschelp.c プロジェクト: fbtestrepo/hw
extern void PopulateHelpDoc (
  DoC d,
  CharPtr filename
)

{
  FonT  fnt;
  FILE  *fp;
  Char  path [PATH_MAX];

  if (d == NULL || StringHasNoText (filename)) return;

  fp = OpenAFile (filename, path);
  if (fp == NULL) return;
  FileClose (fp);

#ifdef WIN_MSWIN
  fnt = systemFont;
#else
  fnt = programFont;
#endif

  DisplayFancy (d, path, &helpParFmt, &helpColFmt, fnt, 0);
}
コード例 #30
0
ファイル: idcleanscan.c プロジェクト: hsptools/hsp-wrap
Int2 Main (void)

{
  AsnIoPtr      aop = NULL;
  AsnModulePtr  amp;
  AsnTypePtr    atp_bss, atp_ss, atp_se;
  BioseqSet     bss;
  FILE          *fp;
  ValNodePtr    head, vnp;
  Char          path [PATH_MAX];
  CharPtr       progname, str, subfile;

  ErrSetFatalLevel (SEV_MAX);
  ErrClearOptFlags (EO_SHOW_USERSTR);
  UseLocalAsnloadDataAndErrMsg ();
  ErrPathReset ();

  if (! AllObjLoad ()) {
    Message (MSG_FATAL, "AllObjLoad failed");
    return 1;
  }
  if (! SubmitAsnLoad ()) {
    Message (MSG_FATAL, "SubmitAsnLoad failed");
    return 1;
  }
  if (! SeqCodeSetLoad ()) {
    Message (MSG_FATAL, "SeqCodeSetLoad failed");
    return 1;
  }
  if (! GeneticCodeTableLoad ()) {
    Message (MSG_FATAL, "GeneticCodeTableLoad failed");
    return 1;
  }

  MemSet ((Pointer) &bss, 0, sizeof (BioseqSet));

  amp = AsnAllModPtr ();
  if (amp == NULL) {
    Message (MSG_FATAL, "Unable to load AsnAllModPtr");
    return 1;
  }

  atp_bss = AsnFind ("Bioseq-set");
  if (atp_bss == NULL) {
    Message (MSG_FATAL, "Unable to find ASN.1 type Bioseq-set");
    return 1;
  }

  atp_ss = AsnFind ("Bioseq-set.seq-set");
  if (atp_ss == NULL) {
    Message (MSG_FATAL, "Unable to find ASN.1 type Bioseq-set.seq-set");
    return 1;
  }


  atp_se = AsnFind ("Bioseq-set.seq-set.E");
  if (atp_se == NULL) {
    Message (MSG_FATAL, "Unable to find ASN.1 type Bioseq-set.seq-set.E");
    return 1;
  }

  ProgramPath (path, sizeof (path));
  progname = StringRChr (path, DIRDELIMCHR);
  if (progname != NULL) {
    progname++;
  } else {
    progname = "idcleanscan";
  }

  if (! GetArgs (progname, sizeof (myargs) / sizeof (Args), myargs)) {
    return 0;
  }

  fp = FileOpen (myargs [o_argOutputFile].strvalue, "a");
  if (fp == NULL) {
    Message (MSG_FATAL, "FileOpen failed");
    return 1;
  }

  if (StringHasNoText (myargs [p_argInputPath].strvalue)) {

    str = myargs [i_argInputFile].strvalue;
    if (! StringHasNoText (str)) {
      DoReleaseFile (str, myargs [b_argBinaryFile].intvalue, myargs [c_argCompressed].intvalue, fp, aop, NULL);
    }

  } else {

    head = DirCatalog (myargs [p_argInputPath].strvalue);

    if (! StringHasNoText (myargs [s_argSubset].strvalue)) {
      aop = AsnIoOpen (myargs [s_argSubset].strvalue, /* "wb" */ "w");
      AsnOpenStruct (aop, atp_bss, (Pointer) &bss);
      AsnOpenStruct (aop, atp_ss, (Pointer) bss.seq_set);
      /*
      av.intvalue = BioseqseqSet_class_genbank;
      AsnWrite (aop, atp_cls, &av);
      */
    }

    for (vnp = head; vnp != NULL; vnp = vnp->next) {
      if (vnp->choice == 0) {
        str = (CharPtr) vnp->data.ptrvalue;
        if (! StringHasNoText (str)) {
          subfile = myargs [x_argFileSelect].strvalue;
          if (StringHasNoText (subfile) || StringStr (str, subfile) != NULL) {
#ifdef OS_UNIX
            /* printf ("%s\n", str); */
#endif
            DoReleaseFile (str, myargs [b_argBinaryFile].intvalue, myargs [c_argCompressed].intvalue, fp, aop, atp_se);
          }
        }
      }
    }

    if (aop != NULL) {
      AsnCloseStruct (aop, atp_ss, (Pointer) bss.seq_set);
      AsnCloseStruct (aop, atp_bss, (Pointer) &bss);
      AsnIoClose (aop);
    }

    ValNodeFreeData (head);
  }

  FileClose (fp);

  return 0;
}