static Int2 LIBCALLBACK VSMGenericAsnSave (OMProcControlPtr ompcp, CharPtr mode ) { Char filename[255]; SelStructPtr ssp, sel; #ifdef WIN_MAC FILE * fp; #endif ValNodePtr entity_list = NULL, vnp; SelectedSaveData ssd; ssp = ObjMgrGetSelected(); if (ssp == NULL) { return OM_MSG_RET_ERROR; } for (sel = ssp; sel != NULL; sel = sel->next) { for (vnp = entity_list; vnp != NULL && vnp->data.intvalue != sel->entityID; vnp = vnp->next) {} if (vnp == NULL) { ValNodeAddInt (&entity_list, 0, sel->entityID); } } ssd.omp = ObjMgrGet(); /* 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 ssd.aip = AsnIoOpen(filename, mode); ssd.ssp = ssp; for (vnp = entity_list; vnp != NULL; vnp = vnp->next) { SaveSeqLocEntity (vnp->data.intvalue, &ssd); GatherObjectsInEntity (vnp->data.intvalue, 0, NULL, SaveOneSelectedItem, (Pointer) &ssd, NULL); } ValNodeFree (entity_list); AsnIoClose(ssd.aip); ArrowCursor(); } return OM_MSG_RET_DONE; }
LRESULT CMainDlg::OnPrintScreen(WPARAM wParam, LPARAM lParam) { BOOL bAltDown = (BOOL)wParam; HWND hWnd = NULL; if(bAltDown) hWnd = ::GetForegroundWindow(); else hWnd = ::GetDesktopWindow(); // Grab screenshot HBITMAP hScreenshotBmp = GetScreenshot(hWnd, NULL); ASSERT(hScreenshotBmp); // Create file name CString strFile = GetOutputFileName(); // Create full file path/name CString strFilePath = m_strImagePath; strFilePath += strFile; SaveImageAs(hScreenshotBmp, strFilePath); // Clean up dib ::DeleteObject(hScreenshotBmp); return 0; }
void TranscodeDialog::Start() { SetWorking(true); QAbstractItemModel* file_model = ui_->files->model(); TranscoderPreset preset = ui_->format->itemData(ui_->format->currentIndex()) .value<TranscoderPreset>(); // Add jobs to the transcoder for (int i = 0; i < file_model->rowCount(); ++i) { QString filename = file_model->index(i, 0).data(Qt::UserRole).toString(); QString outfilename = GetOutputFileName(filename, preset); transcoder_->AddJob(filename, preset, outfilename); } // Set up the progressbar ui_->progress_bar->setValue(0); ui_->progress_bar->setMaximum(file_model->rowCount() * 100); // Reset the UI queued_ = file_model->rowCount(); finished_success_ = 0; finished_failed_ = 0; UpdateStatusText(); // Start transcoding transcoder_->Start(); // Save the last output format QSettings s; s.beginGroup(kSettingsGroup); s.setValue("last_output_format", preset.extension_); }
void RipCDDialog::ClickedRipButton() { if (ripper_->MediaChanged()) { QMessageBox cdio_fail(QMessageBox::Critical, tr("Error Ripping CD"), tr("Media has changed. Reloading")); cdio_fail.exec(); if (CheckCDIOIsValid()) { BuildTrackListTable(); } else { ui_->tableWidget->clearContents(); } return; } // Add tracks and album information to the ripper. ripper_->ClearTracks(); TranscoderPreset preset = ui_->format->itemData(ui_->format->currentIndex()) .value<TranscoderPreset>(); for (int i = 1; i <= ui_->tableWidget->rowCount(); ++i) { if (!checkboxes_.value(i - 1)->isChecked()) { continue; } QString transcoded_filename = GetOutputFileName( ParseFileFormatString(ui_->format_filename->text(), i)); QString title = track_names_.value(i - 1)->text(); ripper_->AddTrack(i, title, transcoded_filename, preset); } ripper_->SetAlbumInformation( ui_->albumLineEdit->text(), ui_->artistLineEdit->text(), ui_->genreLineEdit->text(), ui_->yearLineEdit->text().toInt(), ui_->discLineEdit->text().toInt(), preset.type_); SetWorking(true); ripper_->Start(); }
Int2 LIBCALLBACK VSMFastaSortedProtSave (Pointer data) { OMProcControlPtr ompcp; Char filename[255]; FILE * fp; ValNode vn; SeqEntryPtr sep = NULL; ompcp = (OMProcControlPtr)data; if (ompcp == NULL) return OM_MSG_RET_ERROR; switch(ompcp->input_itemtype) { case OBJ_SEQENTRY: case OBJ_BIOSEQ: case OBJ_BIOSEQSET: break; default: ErrPostEx(SEV_ERROR, 0,0,"ToFasta: Can only write Seq-entry, Bioseq, or Bioseq-set"); return OM_MSG_RET_ERROR; } if (ompcp->input_choicetype == OBJ_SEQENTRY) sep = (SeqEntryPtr)(ompcp->input_choice); else { vn.next = NULL; vn.data.ptrvalue = ompcp->input_data; if (ompcp->input_itemtype == OBJ_BIOSEQ) vn.choice = 1; else vn.choice = 2; sep = &vn; } 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 fp = FileOpen(filename, "w"); WriteSortedProteinsToFile (fp, sep); FileClose(fp); ArrowCursor(); } return OM_MSG_RET_DONE; }
static void Cn3D_KinBrowseProc(ButtoN b) { Char dfault[32]; Char path[256]; path[0] = '\0'; dfault[0] = '\0'; if (GetOutputFileName(path, sizeof(path), dfault)) { SetTitle(Cn3D_tKinSave, path); Cn3D_KinEnableProc(NULL); } return; }
Int2 LIBCALLBACK VSMSaveSetsAsFiles (Pointer data) { Char filename[255]; SelStructPtr ssp, sel; ValNodePtr entity_list = NULL, vnp; SetSaveData ssd; OMProcControlPtr ompcp; ompcp = (OMProcControlPtr) data; ssp = ObjMgrGetSelected(); if (ssp == NULL) { Message (MSG_ERROR, "Nothing selected!"); return OM_MSG_RET_ERROR; } /* get file name to use */ filename[0] = '\0'; if (GetOutputFileName(filename, (size_t)254, NULL)) { WatchCursor(); ssd.file_base = filename; ssd.file_num = 1; ssd.sel = ssp; /* get list of entity IDs */ for (sel = ssp; sel != NULL; sel = sel->next) { if (sel->itemtype != OBJ_BIOSEQSET) { continue; } for (vnp = entity_list; vnp != NULL && vnp->data.intvalue != sel->entityID; vnp = vnp->next) {} if (vnp == NULL) { ValNodeAddInt (&entity_list, 0, sel->entityID); GatherObjectsInEntity (sel->entityID, 0, NULL, SaveSetsInOneSelectedSet, (Pointer) &ssd, NULL); } } ValNodeFree (entity_list); ArrowCursor(); } return OM_MSG_RET_DONE; }
void RipCD::ThreadClickedRipButton() { temporary_directory_ = Utilities::MakeTempDir() + "/"; finished_success_ = 0; finished_failed_ = 0; ui_->progress_bar->setMaximum(NumTracksToRip() * 2 * 100); // Set up progress bar emit(SignalUpdateProgress()); for (int i = 1; i <= i_tracks_; i++) { if (!checkboxes_.value(i - 1)->isChecked()) { continue; } tracks_to_rip_.append(i); QString filename = temporary_directory_ + ParseFileFormatString(ui_->format_filename->text(), i) + ".wav"; QFile* destination_file = new QFile(filename); destination_file->open(QIODevice::WriteOnly); lsn_t i_first_lsn = cdio_get_track_lsn(cdio_, i); lsn_t i_last_lsn = cdio_get_track_last_lsn(cdio_, i); WriteWAVHeader(destination_file, (i_last_lsn - i_first_lsn + 1) * CDIO_CD_FRAMESIZE_RAW); QByteArray buffered_input_bytes(CDIO_CD_FRAMESIZE_RAW, '\0'); for (lsn_t i_cursor = i_first_lsn; i_cursor <= i_last_lsn; i_cursor++) { if (cdio_read_audio_sector(cdio_, buffered_input_bytes.data(), i_cursor) == DRIVER_OP_SUCCESS) { destination_file->write(buffered_input_bytes.data(), buffered_input_bytes.size()); } else { qLog(Error) << "CD read error"; break; } } finished_success_++; emit(SignalUpdateProgress()); TranscoderPreset preset = ui_->format->itemData(ui_->format->currentIndex()) .value<TranscoderPreset>(); QString outfilename = GetOutputFileName(filename, preset); transcoder_->AddJob(filename, preset, outfilename); } emit(RippingComplete()); }
LRESULT CMainDlg::OnSelectionComplete(WPARAM wParam, LPARAM lParam) { // Remove mouse hook ActivateSelectionHook(FALSE); // Grab screenshot HBITMAP hScreenshotBmp = NULL; if((m_hHilightWnd) && (::IsWindow(m_hHilightWnd))) hScreenshotBmp = GetScreenshot(m_hHilightWnd, NULL); // Check if we were launched from tray menu if(!m_bStayInTray) { // Uncheck button CButton* pBtn = (CButton*)GetDlgItem(IDC_WIN_SELECT); ASSERT(pBtn); pBtn->SetCheck(0); // Restore self ShowWindow(SW_RESTORE); } m_bStayInTray = FALSE; // Do not continue if aquiring screenshot failed if(!hScreenshotBmp) return -1; // Create file name CString strFile = GetOutputFileName(); // Create full file path/name CString strFilePath = m_strImagePath; strFilePath += strFile; // Save screenshot as jpeg SaveImageAs(hScreenshotBmp, strFilePath); // Clean up dib ::DeleteObject(hScreenshotBmp); return 0; }
static void Cn3D_PNGSaveProc(IteM i) { Char fname[PATH_MAX]; Char defname[32]; PDNMS pdnmsThis = GetSelectedModelstruc(); fname[0] = '\0'; defname[0] = '\0'; if (pdnmsThis == NULL) StringNCpy_0(defname, pdnmsThis ? GetStrucStrings(pdnmsThis, PDB_ACC) : "cn3d", sizeof(defname) - 4); StringCat(defname, ".png"); if (GetOutputFileName(fname, sizeof(fname), defname)) { Nlm_SaveImagePNG(fname); } }
static void Cn3D_GifSaveProc(IteM i) { Char fname[PATH_MAX]; Char defname[32]; PDNMS pdnmsThis = GetSelectedModelstruc(); fname[0] = '\0'; defname[0] = '\0'; if (pdnmsThis == NULL) StringNCpy_0(defname, pdnmsThis ? GetStrucStrings(pdnmsThis, PDB_ACC) : "cn3d", sizeof(defname) - 4); StringCat(defname, ".gif"); if (GetOutputFileName(fname, sizeof(fname), defname)) { SaveImageGIF(Nlm_GetViewerImage3D(Cn3D_v3d), fname); } }
int main() { for (int testNumber = 3; testNumber <= 120; ++testNumber) { std::cout << testNumber << std::endl; const std::string inputFileName = GetInputFileName(testNumber); const std::string outputFileName = GetOutputFileName(testNumber); std::cout << " " << inputFileName << " " << outputFileName << std::endl; std::string s, t; if (testNumber & 1) { s = GetRandString(); t = GetRandString(); } else { t = GetRandString(); int n = t.length(); int l = GetRandIntInRange(1, n); int r = GetRandIntInRange(1, n); if (l > r) { std::swap(l, r); } s = t.substr(l, r - l + 1); } std::ofstream inputFile(inputFileName); inputFile << s << std::endl; inputFile << t << std::endl; inputFile.close(); std::ofstream outputFile(outputFileName); outputFile << GetOccurrences(s, t) << std::endl; outputFile.close(); } return 0; }
LRESULT CMainDlg::OnDrawComplete(WPARAM wParam, LPARAM lParam) { USES_CONVERSION; // Remove mouse hook ActivateSelectionHook(FALSE); // Get screenshot rect CRect rScreenshot(m_ptFirst, m_ptLast); rScreenshot.NormalizeRect(); // Force repaint of screenshot area /*HWND hDesktop = ::GetDesktopWindow(); if((hDesktop) && (::IsWindow(hDesktop))) { ::InvalidateRect(hDesktop, NULL, TRUE); ::UpdateWindow(hDesktop); ::RedrawWindow(hDesktop, NULL, NULL, RDW_FRAME| RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN); } // Grab screenshot HBITMAP hScreenshotBmp = GetScreenshot(::GetDesktopWindow(), &rScreenshot); */ // Crop out selection area from saved ddb of entire desktop HBITMAP hScreenshotBmp = CropDDB(m_hTmpDraw, rScreenshot); ::DeleteObject(m_hTmpDraw); m_hTmpDraw = NULL; // Check if we were launched from tray menu if(!m_bStayInTray) { // Uncheck button CButton* pBtn = (CButton*)GetDlgItem(IDC_SCREEN_DRAW); ASSERT(pBtn); pBtn->SetCheck(0); // Restore self ShowWindow(SW_RESTORE); } m_bStayInTray = FALSE; // Do not continue if aquiring screenshot failed if(!hScreenshotBmp) return -1; // Create file name CString strFile = GetOutputFileName(); // Create full file path/name CString strFilePath = m_strImagePath; strFilePath += strFile; // Save screenshot as jpeg SaveImageAs(hScreenshotBmp, strFilePath); // Clean up dib ::DeleteObject(hScreenshotBmp); return 0; }
bool ReflectionParser::ProcessFile(std::string const & fileName, bool InProcessModule) { if (!InProcessModule && !m_sourceCache->RequestGenerate(fileName)) return true; Clear(); m_currentFile = fileName; m_index = clang_createIndex(true, false); std::vector<const char *> arguments; for (auto &argument : m_options.arguments) { // unescape flags boost::algorithm::replace_all(argument, "\\-", "-"); arguments.emplace_back(argument.c_str()); } m_translationUnit = clang_createTranslationUnitFromSourceFile( m_index, fileName.c_str(), static_cast<int>(arguments.size()), arguments.data(), 0, nullptr ); auto cursor = clang_getTranslationUnitCursor(m_translationUnit); try { Namespace tempNamespace; buildClasses(cursor, tempNamespace); tempNamespace.clear(); if (ContainsModule() && !InProcessModule) { if (m_classes.size() > 1) { EMIT_ERROR("You can't implement any other classes in one file with module class"); } return false; } if (RequestGenerate()) { std::string fileId = GetFileID(fileName); std::stringstream outCode; // includes outCode << "#include <memory>\n\n"; outCode << "#include \"sc-memory/cpp/sc_memory.hpp\"\n\n\n"; outCode << "#include \"sc-memory/cpp/sc_event.hpp\"\n\n\n"; for (auto it = m_classes.begin(); it != m_classes.end(); ++it) { Class const * klass = *it; if (klass->ShouldGenerate()) { klass->GenerateCode(fileId, outCode, this); } } /// write ScFileID definition outCode << "\n\n#undef ScFileID\n"; outCode << "#define ScFileID " << fileId; // generate output file boost::filesystem::path outputPath(m_options.outputPath); outputPath /= boost::filesystem::path(GetOutputFileName(fileName)); std::ofstream outputFile(outputPath.string()); outputFile << outCode.str(); outputFile << std::endl << std::endl; outputFile.close(); } clang_disposeIndex(m_index); clang_disposeTranslationUnit(m_translationUnit); } catch (Exception e) { clang_disposeIndex(m_index); clang_disposeTranslationUnit(m_translationUnit); EMIT_ERROR(e.GetDescription()); } return true; }
static Int2 VSMExportFeatureTable (OMProcControlPtr ompcp, Boolean show_nucs, Boolean show_prots, Boolean hide_sources, Boolean suppress_protein_ids, Boolean export_only_selected) { Char filename[255]; ValNode vn; SeqEntryPtr sep = NULL; FeatureTableData ftd; SeqAnnotPtr sap = NULL; BioseqPtr fake_bsp = NULL; SeqFeatPtr first_feat = NULL; switch(ompcp->input_itemtype) { case OBJ_SEQENTRY: case OBJ_BIOSEQ: case OBJ_BIOSEQSET: case OBJ_SEQFEAT: break; case OBJ_SEQANNOT: sap = (SeqAnnotPtr) ompcp->input_data; if (sap== NULL) { ErrPostEx(SEV_ERROR, 0,0,"ToFasta: Can't write NULL Seq-annot"); return OM_MSG_RET_ERROR; } else if (sap->type != 1) { ErrPostEx(SEV_ERROR, 0,0,"ToFasta: Can only write Feature Table Seq-annot"); return OM_MSG_RET_ERROR; } else if (sap->data == NULL) { ErrPostEx(SEV_ERROR, 0,0,"ToFasta: Can't write empty Feature Table Seq-annot"); return OM_MSG_RET_ERROR; } break; default: ErrPostEx(SEV_ERROR, 0,0,"ToFasta: Can only write Seq-entry, Feature Table Seq-annot, Bioseq, or Bioseq-set"); return OM_MSG_RET_ERROR; } ftd.show_nucs = show_nucs; ftd.show_prots = show_prots; ftd.hide_sources = hide_sources; ftd.suppress_protein_ids = suppress_protein_ids; ftd.export_only_selected = export_only_selected; if (ompcp->input_itemtype == OBJ_SEQFEAT) { sep = GetTopSeqEntryForEntityID (ompcp->input_entityID); } else if (ompcp->input_choicetype == OBJ_SEQENTRY) { sep = (SeqEntryPtr)(ompcp->input_choice); } else if (ompcp->input_itemtype == OBJ_SEQANNOT) { sep = GetTopSeqEntryForEntityID (ompcp->input_entityID); if (sep == NULL) { if (sap != NULL) { fake_bsp = BioseqNew(); first_feat = (SeqFeatPtr) sap->data; fake_bsp->id = SeqIdDup (SeqLocId (first_feat->location)); fake_bsp->annot = sap; if (first_feat->data.choice == SEQFEAT_PROT) { fake_bsp->mol = Seq_mol_aa; } else { fake_bsp->mol = Seq_mol_dna; } fake_bsp->repr = Seq_repr_raw; fake_bsp->length = FindNecessaryBioseqLength (first_feat); /* create SeqEntry for temporary bioseq to live in */ sep = SeqEntryNew (); sep->choice = 1; sep->data.ptrvalue = fake_bsp; SeqMgrSeqEntry (SM_BIOSEQ, (Pointer) fake_bsp, sep); } } } else { vn.next = NULL; vn.data.ptrvalue = ompcp->input_data; if (ompcp->input_itemtype == OBJ_BIOSEQ) vn.choice = 1; else vn.choice = 2; sep = &vn; } filename[0] = '\0'; if (GetOutputFileName(filename, (size_t)254, NULL)) { WatchCursor(); #ifdef WIN_MAC ftd.fp = FileOpen (filename, "r"); if (ftd.fp != NULL) { FileClose (ftd.fp); } else { FileCreate (filename, "TEXT", "ttxt"); } #endif ftd.fp = FileOpen(filename, "w"); VisitBioseqsInSep (sep, &ftd, VSMExportFeatureTableBioseqCallback); FileClose(ftd.fp); ArrowCursor(); } if (fake_bsp != NULL) { fake_bsp->annot = NULL; fake_bsp->idx.deleteme = TRUE; DeleteMarkedObjects (fake_bsp->idx.entityID, 0, NULL); } return OM_MSG_RET_DONE; }
Int2 LIBCALLBACK VSMFastaProtSaveWithProduct ( Pointer data ) { Char filename[255]; FastaExportOptionsData fe; ValNode vn; SeqEntryPtr sep = NULL; SeqFeatPtr sfp; SeqLocPtr slp; Uint1 code; BioseqPtr bsp; OMProcControlPtr ompcp; if ((ompcp = (OMProcControlPtr) data) == NULL) { return OM_MSG_RET_ERROR; } sfp = NULL; switch(ompcp->input_itemtype) { case OBJ_SEQENTRY: case OBJ_BIOSEQ: case OBJ_BIOSEQSET: break; case OBJ_SEQFEAT: sfp = (SeqFeatPtr) ompcp->input_data; if (sfp == NULL || (sfp->data.choice != SEQFEAT_CDREGION && sfp->data.choice != SEQFEAT_PROT)) return OM_MSG_RET_ERROR; break; default: ErrPostEx(SEV_ERROR, 0,0,"ToFasta: Can only write Seq-entry, Bioseq, or Bioseq-set"); return OM_MSG_RET_ERROR; } if (sfp != NULL) { } else if (ompcp->input_choicetype == OBJ_SEQENTRY) sep = (SeqEntryPtr)(ompcp->input_choice); else { vn.next = NULL; vn.data.ptrvalue = ompcp->input_data; if (ompcp->input_itemtype == OBJ_BIOSEQ) vn.choice = 1; else vn.choice = 2; sep = &vn; } filename[0] = '\0'; if (GetOutputFileName(filename, (size_t)254, NULL)) { WatchCursor(); #ifdef WIN_MAC fe.fp = FileOpen (filename, "r"); if (fe.fp != NULL) { FileClose (fe.fp); } else { FileCreate (filename, "TEXT", "ttxt"); } #endif fe.fp = FileOpen(filename, "w"); if (sfp != NULL) { code = Seq_code_ncbieaa; slp = sfp->location; if (sfp->data.choice == SEQFEAT_CDREGION) { slp = sfp->product; } bsp = GetBioseqGivenSeqLoc (slp, ompcp->input_entityID); if (slp != NULL && bsp != NULL) { SeqLocFastaStream (slp, fe.fp, STREAM_EXPAND_GAPS | STREAM_CORRECT_INVAL, 70, 0, 0); } } else { fe.flags = STREAM_EXPAND_GAPS | STREAM_CORRECT_INVAL; fe.linelen = 70; fe.blocklen = 0; fe.grouplen = 0; VisitBioseqsInSep (sep, &fe, WriteOneProteinWithProduct); } FileClose(fe.fp); ArrowCursor(); } return OM_MSG_RET_DONE; }
static Int2 LIBCALLBACK VSMGenericFastaSave (OMProcControlPtr ompcp, Boolean is_na) { Char filename[255]; FILE * fp; ValNode vn; SeqEntryPtr sep = NULL; SeqFeatPtr sfp; SeqLocPtr slp; Uint1 code; BioseqPtr bsp; sfp = NULL; switch(ompcp->input_itemtype) { case OBJ_SEQENTRY: case OBJ_BIOSEQ: case OBJ_BIOSEQSET: break; case OBJ_SEQFEAT: sfp = (SeqFeatPtr) ompcp->input_data; if (sfp == NULL) return OM_MSG_RET_ERROR; break; default: ErrPostEx(SEV_ERROR, 0,0,"ToFasta: Can only write Seq-entry, Bioseq, or Bioseq-set"); return OM_MSG_RET_ERROR; } if (sfp != NULL) { } else if (ompcp->input_choicetype == OBJ_SEQENTRY) sep = (SeqEntryPtr)(ompcp->input_choice); else { vn.next = NULL; vn.data.ptrvalue = ompcp->input_data; if (ompcp->input_itemtype == OBJ_BIOSEQ) vn.choice = 1; else vn.choice = 2; sep = &vn; } 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 fp = FileOpen(filename, "w"); if (sfp != NULL) { if (is_na) code = Seq_code_iupacna; else code = Seq_code_ncbieaa; slp = sfp->location; if (sfp->data.choice == SEQFEAT_CDREGION && (! is_na)) { slp = sfp->product; } /* spp = SeqPortNewByLoc (slp, code); */ bsp = GetBioseqGivenSeqLoc (slp, ompcp->input_entityID); /* if (spp != NULL && bsp != NULL) { while (FastaSeqLine(spp, buf, 70, is_na)) FastaFileFunc(bsp, FASTA_SEQLINE, buf, sizeof (buf), (Pointer)fp); SeqPortFree(spp); FastaFileFunc(bsp, FASTA_EOS, buf, sizeof (buf), (Pointer)fp); } */ if (slp != NULL && bsp != NULL) { SeqLocFastaStream (slp, fp, STREAM_EXPAND_GAPS | STREAM_CORRECT_INVAL, 70, 0, 0); } } else { /* SeqEntryToFasta(sep, fp, is_na); */ SeqEntryFastaStreamEx (sep, fp, STREAM_EXPAND_GAPS | STREAM_CORRECT_INVAL, 70, 0, 0, is_na, !is_na, FALSE, !is_na, FALSE); } FileClose(fp); ArrowCursor(); } return OM_MSG_RET_DONE; }
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; }