예제 #1
0
파일: vsmfile.c 프로젝트: hsptools/hsp-wrap
Int2 LIBCALLBACK VSMDescriptorAsnSave (Pointer data)
{
  OMProcControlPtr ompcp;
  Char filename[255];
  SelStructPtr  ssp, sel;
  SeqDescrPtr   sdp;
  BioseqPtr     bsp;
  SeqEntryPtr   sep;
  SeqMgrDescContext dcontext;
#ifdef WIN_MAC
  FILE * fp;
#endif
  ValNodePtr vnp;
  SaveSetSdpData sd;
  ValNodePtr obj_list = NULL;

  ompcp = (OMProcControlPtr)data;
  if (ompcp == NULL) return OM_MSG_RET_ERROR;

  sd.already_have_molinfo = FALSE;
  ssp = ObjMgrGetSelected();
  if (ssp == NULL)
    {
    Message (MSG_ERROR, "You must select a sequence or set from which descriptors should be saved");
    return OM_MSG_RET_DONE;
  } else {
      for (sel = ssp; sel != NULL; sel = sel->next)
      {
      GatherItem (sel->entityID, sel->itemID, sel->itemtype,
                (Pointer) &obj_list, AddToSaveList);
    }
  }

  /* get file name to use */    
    filename[0] = '\0';
    if (GetOutputFileName(filename, (size_t)254, NULL))
    {
        WatchCursor();
#ifdef WIN_MAC
        fp = FileOpen (filename, "r");
        if (fp != NULL) {
            FileClose (fp);
        } else {
            FileCreate (filename, "TEXT", "ttxt");
        }
#endif

        sd.aip = AsnIoOpen(filename, "w");
      for (vnp = obj_list; vnp != NULL; vnp = vnp->next)
      {
      switch (vnp->choice) {
        case OBJ_SEQDESC:
          sdp = (SeqDescrPtr) vnp->data.ptrvalue;
          SeqDescAsnWrite (sdp, sd.aip, NULL);
          AsnPrintNewLine (sd.aip);
          AsnIoFlush (sd.aip);
          break;
        case OBJ_BIOSEQ:
          bsp = (BioseqPtr) vnp->data.ptrvalue;
          for (sdp = SeqMgrGetNextDescriptor (bsp, NULL, 0, &dcontext);
               sdp != NULL;
               sdp = SeqMgrGetNextDescriptor (bsp, sdp, 0, &dcontext)) {
            if (sdp->choice != Seq_descr_source
                && sdp->choice != Seq_descr_pub
                && sdp->choice != Seq_descr_molinfo
                && sdp->choice != Seq_descr_comment) continue;
            SeqDescAsnWrite (sdp, sd.aip, NULL);
            AsnPrintNewLine (sd.aip);
            AsnIoFlush (sd.aip);
          }
          break;
        case OBJ_BIOSEQSET:
          sep = SeqMgrGetSeqEntryForData (vnp->data.ptrvalue);
          VisitDescriptorsInSep (sep, &sd, SaveSetDescriptors);
          break;
      }              
    }   
        AsnIoClose(sd.aip);
        ArrowCursor();
    }
    
    return OM_MSG_RET_DONE;  
}
예제 #2
0
static void DoRecord (SeqEntryPtr sep, Pointer userdata)

{
  BioseqPtr     bsp;
  SeqEntryPtr   nsep;
  ScanDataPtr   sdp;

  sdp = (ScanDataPtr) userdata;
  (sdp->recordCount)++;

  nsep = FindNthBioseq (sep, 1);
  if (nsep != NULL && IS_Bioseq (nsep)) {
    bsp = (BioseqPtr) nsep->data.ptrvalue;
    if (bsp != NULL) {
      SeqIdWrite (bsp->id, sdp->buf, PRINTID_FASTA_LONG, sizeof (sdp->buf));
    }
  }
#ifdef OS_UNIX
  /* printf ("%s\n", sdp->buf); */
#endif

  VisitPubdescsInSep (sep, (Pointer) sdp, DoThesis);

  /* check for 'genomic DNA' in DoTitle suppressed for bulk submissions */

  sdp->bulk = FALSE;
  VisitDescriptorsInSep (sep, (Pointer) sdp, LookForBulk);
  VisitDescriptorsInSep (sep, (Pointer) sdp, DoTitle);

  VisitFeaturesInSep (sep, (Pointer) sdp, DoImpCDSandTrna);

  /* index for pseudo cds, impfeat peptides codon frame */

  SeqMgrIndexFeatures (0, sep->data.ptrvalue);

  VisitFeaturesInSep (sep, (Pointer) sdp, DoPseudoCDS);

  VisitFeaturesInSep (sep, (Pointer) sdp, DoPeptide);

  /* now cleanup, index for overlapping peptides */

  SeriousSeqEntryCleanup (sep, NULL, NULL);
  SeqMgrIndexFeatures (0, sep->data.ptrvalue);

  VisitBioseqsInSep (sep, (Pointer) sdp, DoProteins);

  /*
  VisitBioseqsInSep (sep, (Pointer) sdp, DoGraphs);
  */

#if 0
  {
    Boolean  hasUser = FALSE;

    VisitFeaturesInSep (sep, (Pointer) &hasUser, DoUser);

    if (hasUser && sdp->aop != NULL && sdp->atp_se != NULL) {
      SeqEntryAsnWrite (sep, sdp->aop, sdp->atp_se);
    }
  }
#endif
}
예제 #3
0
static void DoProcess (
  SeqEntryPtr sep,
  Uint2 entityID,
  CSpeedFlagPtr cfp
)

{
  Char            id [64];
  ErrSev          oldErrSev;
  ValidStructPtr  vsp;

  if (sep == NULL || cfp == NULL) return;

  if (StringChr (cfp->clean, 't') != NULL) {
    VisitDescriptorsInSep (sep, NULL, MarkTitles);
    DeleteMarkedObjects (entityID, 0, NULL);
  }
  if (StringChr (cfp->clean, 'a') != NULL) {
    AssignIDsInEntity (entityID, 0, NULL);
  }
  if (StringChr (cfp->clean, 'b') != NULL) {
    BasicSeqEntryCleanup (sep);
  }
  if (StringChr (cfp->clean, 's') != NULL) {
    SeriousSeqEntryCleanup (sep, NULL, NULL);
  }

  if (StringChr (cfp->index, 'f') != NULL) {
    SeqMgrIndexFeatures (entityID, 0);
  }

  if (StringChr (cfp->seq, 'c') != NULL) {
    VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaExist);
  }
  if (StringChr (cfp->seq, 'C') != NULL) {
    VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaRegen);
  }
  if (StringChr (cfp->seq, 's') != NULL) {
    VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaSeq);
  }
  if (StringChr (cfp->seq, 'S') != NULL) {
    if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
      SeqMgrIndexFeatures (entityID, 0);
    }
    VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaSeq);
  }
  if (StringChr (cfp->seq, 'r') != NULL) {
    VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaRaw);
  }
  if (StringChr (cfp->seq, 'd') != NULL) {
    VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaDefline);
  }
  if (StringChr (cfp->seq, 'D') != NULL) {
    if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
      SeqMgrIndexFeatures (entityID, 0);
    }
    VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaDefline);
  }
  if (StringChr (cfp->seq, 'T') != NULL) {
    VisitDescriptorsInSep (sep, NULL, MarkTitles);
    DeleteMarkedObjects (entityID, 0, NULL);
    SeqMgrIndexFeatures (entityID, 0);
    VisitBioseqsInSep (sep, (Pointer) cfp, DoFastaDefline);
  }
  if (StringChr (cfp->seq, 'x') != NULL) {
    VisitBioseqsInSep (sep, (Pointer) cfp, DoNewFastaDefline);
  }
  if (StringChr (cfp->seq, 'X') != NULL) {
    VisitDescriptorsInSep (sep, NULL, MarkTitles);
    DeleteMarkedObjects (entityID, 0, NULL);
    SeqMgrIndexFeatures (entityID, 0);
    VisitBioseqsInSep (sep, (Pointer) cfp, DoNewFastaDefline);
  }
  
  if (StringChr (cfp->seq, 'f') != NULL) {
    VisitFeaturesInSep (sep, (Pointer) cfp, DoFastaFeat);
  }
  if (StringChr (cfp->seq, 't') != NULL) {
    VisitFeaturesInSep (sep, (Pointer) cfp, DoFastaTrans);
  }

  if (StringChr (cfp->feat, 'v') != NULL) {
    VisitFeaturesInSep (sep, NULL, DoVisitFeaturesTest);
  }
  if (StringChr (cfp->feat, 'g') != NULL) {
    if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
      SeqMgrIndexFeatures (entityID, 0);
    }
    VisitFeaturesInSep (sep, (Pointer) cfp, DoGeneOverlapPrintTest);
  }
  if (StringChr (cfp->feat, 'h') != NULL) {
    if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
      SeqMgrIndexFeatures (entityID, 0);
    }
    VisitFeaturesInSep (sep, (Pointer) cfp, DoGeneOverlapSpeedTest);
  }
  if (StringChr (cfp->feat, 'x') != NULL) {
  }
  if (StringChr (cfp->feat, 'o') != NULL) {
  }
  if (StringChr (cfp->feat, 'd') != NULL) {
  }
  if (StringChr (cfp->feat, 't') != NULL) {
    SeqEntryToGnbk (sep, NULL, FTABLE_FMT, SEQUIN_MODE, NORMAL_STYLE,
                    0, 0, SHOW_PROT_FTABLE, NULL, cfp->ofp);
  }
  if (StringChr (cfp->feat, 's') != NULL) {
    if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
      SeqMgrIndexFeatures (entityID, 0);
    }
    cfp->nucbsp = FindNucBioseq (sep);
    if (cfp->nucbsp != NULL) {
      BioseqToGeneticCode (cfp->nucbsp, &(cfp->genCode), NULL, NULL, NULL, 0, NULL);
      SeqIdWrite (cfp->nucbsp->id, id, PRINTID_FASTA_LONG, sizeof (id) - 1);
      fprintf (cfp->ofp, "%s\n", id);
      VisitBioseqsInSep (sep, (Pointer) cfp, DoSuggestIntervals);
      cfp->nucbsp = NULL;
      cfp->genCode = 0;
    }
  }
  if (StringChr (cfp->feat, 'S') != NULL) {
    if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
      SeqMgrIndexFeatures (entityID, 0);
    }
    cfp->nucbsp = FindNucBioseq (sep);
    if (cfp->nucbsp != NULL) {
      BioseqToGeneticCode (cfp->nucbsp, &(cfp->genCode), NULL, NULL, NULL, 0, NULL);
      SetBatchSuggestNucleotide (cfp->nucbsp, cfp->genCode);
      SeqIdWrite (cfp->nucbsp->id, id, PRINTID_FASTA_LONG, sizeof (id) - 1);
      fprintf (cfp->ofp, "%s\n", id);
      VisitBioseqsInSep (sep, (Pointer) cfp, DoSuggestIntervals);
      ClearBatchSuggestNucleotide ();
      cfp->nucbsp = NULL;
      cfp->genCode = 0;
    }
  }
  if (StringChr (cfp->feat, 'c') != NULL) {
    VisitFeaturesInSep (sep, (Pointer) cfp, DoVisitCodingRegions);
  }

  if (StringChr (cfp->desc, 'b') != NULL) {
  }
  if (StringChr (cfp->desc, 't') != NULL) {
  }

  if (StringChr (cfp->verify, 'v') != NULL) {
    if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
      SeqMgrIndexFeatures (entityID, 0);
    }
    vsp = ValidStructNew ();
    if (vsp != NULL) {
      vsp->useSeqMgrIndexes = TRUE;
      vsp->suppressContext = TRUE;
      vsp->seqSubmitParent = TRUE;
      vsp->testLatLonSubregion = TRUE;
      oldErrSev = ErrSetMessageLevel (SEV_NONE);
      vsp->errfunc = ValidCallback;
      vsp->userdata = (Pointer) cfp->ofp;
      /* vsp->convertGiToAccn = FALSE; */
      ValidateSeqEntry (sep, vsp);
      ValidStructFree (vsp);
      ErrSetMessageLevel (oldErrSev);
    }
  }
  if (StringChr (cfp->verify, 'b') != NULL) {
    if (SeqMgrFeaturesAreIndexed (entityID) == 0) {
      SeqMgrIndexFeatures (entityID, 0);
    }
    SeqEntryToGnbk (sep, NULL, GENBANK_FMT, SEQUIN_MODE, NORMAL_STYLE,
                    0, 0, 0, NULL, cfp->ofp);
  }

  if (cfp->ofp != NULL) {
    fflush (cfp->ofp);
  }
}