void Logger::open(DWORD pId) { try { openService(logNumber, filename); } catch (std::exception&) { char buf[10]; _ltoa_s(logNumber, buf, 10, 10); filename = std::string("log_XXX_00_00_00_" + std::string(buf)); } char buf[10]; _ltoa_s(pId, buf, 10, 10); out.open(filename); if (!out) { std::cout << "Can't open file" << std::endl; throw OpenFileError("Error opening file."); } out << "############################################################################" << std::endl; out << "============ The log file for a process with initial id: ============" << std::endl << buf << std::endl; out << "############################################################################" << std::endl << std::endl; out.close(); }
ConnectedLogFile::ConnectedLogFile(SessionConnection& connection, const boost::filesystem::path& path) : connection(connection), file(), error_string(), file_path(path) { std::future<std::unique_ptr<prot::Receivable>> recv = connection.send(prot::File(path)); recv.wait(); recv.get()->act(*this); if (!error_string.empty()) throw OpenFileError(path, error_string); }
// Calculate secondary structure for given HMM and return prediction void CalculateSS(HMM& q, char *ss_pred, char *ss_conf) { char tmpfile[]="/tmp/hhCalcSSXXXXXX"; if (mkstemp(tmpfile) == -1) { cerr << "ERROR! Could not create tmp-file!\n"; exit(4); } // Write log-odds matrix from q to tmpfile.mtx char filename[NAMELEN]; FILE* mtxf = NULL; strcpy(filename,tmpfile); strcat(filename,".mtx"); mtxf = fopen(filename,"w"); if (!mtxf) OpenFileError(filename); fprintf(mtxf,"%i\n",q.L); fprintf(mtxf,"%s\n",q.seq[q.nfirst]+1); fprintf(mtxf,"2.670000e-03\n4.100000e-02\n-3.194183e+00\n1.400000e-01\n2.670000e-03\n4.420198e-02\n-3.118986e+00\n1.400000e-01\n3.176060e-03\n1.339561e-01\n-2.010243e+00\n4.012145e-01\n"); for (int i = 1; i <= q.L; ++i) { fprintf(mtxf,"-32768 "); for (int a = 0; a < 20; ++a) { int tmp = iround(50*flog2(q.p[i][s2a[a]]/pb[s2a[a]])); fprintf(mtxf,"%5i ",tmp); if (a == 0) { // insert logodds value for B fprintf(mtxf,"%5i ",-32768); } else if (a == 18) { // insert logodds value for X fprintf(mtxf,"%5i ",-100); } else if (a == 19) { // insert logodds value for Z fprintf(mtxf,"%5i ",-32768); } } fprintf(mtxf,"-32768 -400\n"); } fclose(mtxf); // Calculate secondary structure CalculateSS(ss_pred, ss_conf, tmpfile); q.AddSSPrediction(ss_pred, ss_conf); // Remove temp-files std::string command = "rm " + (std::string)tmpfile + "*"; runSystem(command,v); }
Logger::Logger(const std::string& nameOfFile, const std::string& cmdLine) { ++logNumber; filename = nameOfFile; out.open(filename); if (!out) { std::cout << "Can't open file" << std::endl; throw OpenFileError("Error opening file."); } out << "############################################################################" << std::endl; out << "============ The log file for a process with command line: ============" << std::endl << cmdLine << std::endl; out << "############################################################################" << std::endl << std::endl; out.close(); }
Prefilter::Prefilter(const char* cs_library, FFindexDatabase* cs219_database) { num_dbs = 0; // Prepare column state lib (context size =1 ) FILE* fin = fopen(cs_library, "r"); if (!fin) OpenFileError(cs_library, __FILE__, __LINE__, __func__); cs_lib = new cs::ContextLibrary<cs::AA>(fin); fclose(fin); cs::TransformToLin(*cs_lib); init_prefilter(cs219_database); }
VOID Directory( IN PCHAR String ) { NTSTATUS Status; HANDLE FileHandle; OBJECT_ATTRIBUTES ObjectAttributes; STRING NameString; IO_STATUS_BLOCK IoStatus; NTSTATUS NtStatus; PFILE_ADIRECTORY_INFORMATION FileInfo; ULONG i; // // Get the filename // simprintf("Directory ", 0); simprintf(String, 0); simprintf("\n", 0); // // Open the file for list directory access // RtlInitString( &NameString, String ); InitializeObjectAttributes( &ObjectAttributes, &NameString, 0, NULL, NULL ); if (!NT_SUCCESS(Status = NtOpenFile( &FileHandle, FILE_LIST_DIRECTORY | SYNCHRONIZE, &ObjectAttributes, &IoStatus, FILE_SHARE_READ, WriteThrough | FILE_DIRECTORY_FILE ))) { OpenFileError( Status , String ); return; } // // zero out the buffer so next time we'll recognize the end of data // for (i = 0; i < BUFFERSIZE; i += 1) { Buffer[i] = 0; } // // Do the directory loop // for (NtStatus = NtQueryDirectoryFile( FileHandle, (HANDLE)NULL, (PIO_APC_ROUTINE)NULL, (PVOID)NULL, &IoStatus, Buffer, BUFFERSIZE, FileADirectoryInformation, FALSE, (PSTRING)NULL, TRUE); NT_SUCCESS(NtStatus); NtStatus = NtQueryDirectoryFile( FileHandle, (HANDLE)NULL, (PIO_APC_ROUTINE)NULL, (PVOID)NULL, &IoStatus, Buffer, BUFFERSIZE, FileADirectoryInformation, FALSE, (PSTRING)NULL, FALSE) ) { if (!NT_SUCCESS(Status = NtWaitForSingleObject(FileHandle, TRUE, NULL))) { // NtPartyByNumber(50); WaitForSingleObjectError( Status ); return; } // // Check the Irp for success // if (!NT_SUCCESS(IoStatus.Status)) { break; } // // For every record in the buffer type out the directory information // // // Point to the first record in the buffer, we are guaranteed to have // one otherwise IoStatus would have been No More Files // FileInfo = (PFILE_ADIRECTORY_INFORMATION)&Buffer[0]; while (TRUE) { // // Print out information about the file // simprintf("%8lx ", FileInfo->FileAttributes); simprintf("%8lx/", FileInfo->EndOfFile.LowPart); simprintf("%8lx ", FileInfo->AllocationSize.LowPart); { CHAR Saved; Saved = FileInfo->FileName[FileInfo->FileNameLength]; FileInfo->FileName[FileInfo->FileNameLength] = 0; simprintf(FileInfo->FileName, 0); FileInfo->FileName[FileInfo->FileNameLength] = Saved; } simprintf("\n", 0); // // Check if there is another record, if there isn't then we // simply get out of this loop // if (FileInfo->NextEntryOffset == 0) { break; } // // There is another record so advance FileInfo to the next // record // FileInfo = (PFILE_ADIRECTORY_INFORMATION)(((PUCHAR)FileInfo) + FileInfo->NextEntryOffset); } // // zero out the buffer so next time we'll recognize the end of data // for (i = 0; i < BUFFERSIZE; i += 1) { Buffer[i] = 0; } } // // Now close the file // if (!NT_SUCCESS(Status = NtClose( FileHandle ))) { CloseError( Status ); } // // And return to our caller // return; }
VOID Read( IN PCHAR FileName, IN ULONG FileTime, IN ULONG FileCount ) { NTSTATUS Status; HANDLE FileHandle; OBJECT_ATTRIBUTES ObjectAttributes; STRING NameString; IO_STATUS_BLOCK IoStatus; LARGE_INTEGER AllocationSize; LARGE_INTEGER ByteOffset; ULONG Count; ULONG Pattern[3]; // // Get the filename // simprintf("Read ", 0); simprintf(FileName, 0); simprintf("\n", 0); // // Open the existing file // AllocationSize = LiFromUlong( FileCount * 4 ); RtlInitString( &NameString, FileName ); InitializeObjectAttributes( &ObjectAttributes, &NameString, 0, NULL, NULL ); if (!NT_SUCCESS(Status = NtOpenFile( &FileHandle, FILE_READ_DATA | FILE_READ_ATTRIBUTES | SYNCHRONIZE, &ObjectAttributes, &IoStatus, 0L, WriteThrough ))) { OpenFileError( Status, FileName ); return; } // // The main loop read in the test pattern our test pattern // is <FileTime> <FileSize> <Count> where count is the current // iteration count for the current test pattern output. // for (Count = 0; Count < FileCount; Count += 1) { ByteOffset = LiFromUlong( Count * 3 * 4 ); if (!NT_SUCCESS(Status = NtReadFile( FileHandle, (HANDLE)NULL, (PIO_APC_ROUTINE)NULL, (PVOID)NULL, &IoStatus, Pattern, 3 * 4, &ByteOffset, (PULONG) NULL ))) { ReadFileError( Status ); return; } if (!NT_SUCCESS(Status = NtWaitForSingleObject(FileHandle, TRUE, NULL))) { WaitForSingleObjectError( Status ); return; } // // check how the read turned out // CheckIoStatus( &IoStatus, 3 * 4, TRUE ); if (!NT_SUCCESS(IoStatus.Status)) { IoStatusError( IoStatus.Status ); break; } // // Now compare the what we read with what we should have read // if ((Pattern[0] != FileTime) || (Pattern[1] != FileCount) || (Pattern[2] != Count)) { printf("**** Read Error ****\n"); NtPartyByNumber( 50 ); return; } } // // Now close the file // if (!NT_SUCCESS(Status = NtClose( FileHandle ))) { CloseError( Status ); } // // And return to our caller // return; }
int main(int argc, const char **argv) { Parameters par(argc, argv); strcpy(par.infile, ""); strcpy(par.outfile, ""); // maximum number of sequences to be written par.nseqdis = par.maxseq - 1; // no filtering for maximum diversity par.Ndiff = 0; ProcessArguments(par); // Check command line input and default values if (!*par.infile) { help(par); HH_LOG(ERROR) << "Input file is missing!" << std::endl; exit(4); } if (!*par.outfile) { help(par); HH_LOG(ERROR) << "Output file is missing!" << std::endl; exit(4); } HH_LOG(INFO) << "Input file = " << par.infile << "\n"; HH_LOG(INFO) << "Output file = " << par.outfile << "\n"; // Reads in an alignment from par.infile into matrix X[k][l] as ASCII FILE* inf = NULL; if (strcmp(par.infile, "stdin")) { inf = fopen(par.infile, "r"); if (!inf) { OpenFileError(par.infile, __FILE__, __LINE__, __func__); } } else { inf = stdin; } Alignment qali(par.maxseq, par.maxres); qali.Read(inf, par.infile, par.mark, par.maxcol, par.nseqdis); fclose(inf); // Convert ASCII to int (0-20),throw out all insert states, record their number in I[k][i] // and store marked sequences in name[k] and seq[k] qali.Compress(par.infile, par.cons, par.maxcol, par.M, par.Mgaps); // substitution matrix flavours float __attribute__((aligned(16))) P[20][20]; float __attribute__((aligned(16))) R[20][20]; float __attribute__((aligned(16))) Sim[20][20]; float __attribute__((aligned(16))) S[20][20]; float __attribute__((aligned(16))) pb[21]; SetSubstitutionMatrix(par.matrix, pb, P, R, S, Sim); // Remove sequences with seq. identity larger than seqid percent (remove the shorter of two) qali.N_filtered = qali.Filter(par.max_seqid, S, par.coverage, par.qid, par.qsc,par.Ndiff); // Atune alignment diversity q.Neff with qsc to value Neff_goal if (par.Neff >= 1.0) { qali.FilterNeff(par.wg, par.mark, par.cons, par.showcons, par.max_seqid, par.coverage, par.Neff, pb, S, Sim); } // Write filtered alignment WITH insert states (lower case) to alignment file qali.WriteToFile(par.outfile, par.append); }
// Read input file (HMM, HHM, or alignment format), and add pseudocounts etc. void ReadAndPrepare(char* infile, HMM& q, Alignment* qali=NULL) { char path[NAMELEN]; // Open query file and determine file type char line[LINELEN]=""; // input line FILE* inf=NULL; if (strcmp(infile,"stdin")) { inf = fopen(infile, "r"); if (!inf) OpenFileError(infile); Pathname(path,infile); } else { inf = stdin; if (v>=2) printf("Reading HMM / multiple alignment from standard input ...\n(To get a help list instead, quit and type %s -h.)\n",program_name); *path='\0'; } fgetline(line,LINELEN-1,inf); // Is it an hhm file? if (!strncmp(line,"NAME",4) || !strncmp(line,"HH",2)) { if (v>=2) cout<<"Query file is in HHM format\n"; // Rewind to beginning of line and read query hhm file rewind(inf); q.Read(inf,path); if (v>=2 && q.Neff_HMM>11.0) fprintf(stderr,"WARNING: HMM %s looks too diverse (Neff=%.1f>11). Better check the underlying alignment... \n",q.name,q.Neff_HMM); // Add transition pseudocounts to query -> q.p[i][a] q.AddTransitionPseudocounts(); if (!*par.clusterfile) { //compute context-specific pseudocounts? // Generate an amino acid frequency matrix from f[i][a] with full pseudocount admixture (tau=1) -> g[i][a] q.PreparePseudocounts(); // Add amino acid pseudocounts to query: q.p[i][a] = (1-tau)*f[i][a] + tau*g[i][a] q.AddAminoAcidPseudocounts(par.pcm, par.pca, par.pcb, par.pcc);; } else { // Add context specific pseudocount to query q.AddContextSpecificPseudocounts(par.pcm); } q.CalculateAminoAcidBackground(); } // ... or is it an a2m/a3m alignment file else if (line[0]=='#' || line[0]=='>') { Alignment* pali; if (qali==NULL) pali=new(Alignment); else pali=qali; if (par.calibrate) { printf("\nError in %s: only HHM files can be calibrated.\n",program_name); printf("Build an HHM file from your alignment with 'hhmake -i %s' and rerun hhsearch with the hhm file\n\n",infile); exit(1); } if (v>=2 && strcmp(infile,"stdin")) cout<<infile<<" is in A2M, A3M or FASTA format\n"; // Read alignment from infile into matrix X[k][l] as ASCII (and supply first line as extra argument) pali->Read(inf,infile,line); // Convert ASCII to int (0-20),throw out all insert states, record their number in I[k][i] // and store marked sequences in name[k] and seq[k] pali->Compress(infile); // Sort out the nseqdis most dissimilar sequences for display in the output alignments pali->FilterForDisplay(par.max_seqid,par.coverage,par.qid,par.qsc,par.nseqdis); // Remove sequences with seq. identity larger than seqid percent (remove the shorter of two) pali->N_filtered = pali->Filter(par.max_seqid,par.coverage,par.qid,par.qsc,par.Ndiff); if (par.Neff>=0.999) pali->FilterNeff(); // Calculate pos-specific weights, AA frequencies and transitions -> f[i][a], tr[i][a] pali->FrequenciesAndTransitions(q); if (v>=2 && q.Neff_HMM>11.0) fprintf(stderr,"WARNING: alignment %s looks too diverse (Neff=%.1f>11). Better check it with an alignment viewer... \n",q.name,q.Neff_HMM); // Add transition pseudocounts to query -> p[i][a] q.AddTransitionPseudocounts(); if (!*par.clusterfile) { //compute context-specific pseudocounts? // Generate an amino acid frequency matrix from f[i][a] with full pseudocount admixture (tau=1) -> g[i][a] q.PreparePseudocounts(); // Add amino acid pseudocounts to query: p[i][a] = (1-tau)*f[i][a] + tau*g[i][a] q.AddAminoAcidPseudocounts(par.pcm, par.pca, par.pcb, par.pcc); } else { // Add context specific pseudocount to query q.AddContextSpecificPseudocounts(par.pcm); } q.CalculateAminoAcidBackground(); if (qali==NULL) delete(pali); } else if (!strncmp(line,"HMMER",5)) { /////////////////////////////////////////////////////////////////////////////////////// // Don't allow HMMER format as input due to the severe loss of sensitivity!!!! (only allowed in HHmake) if (strncmp(program_name,"hhmake",6)) { cerr<<endl<<"Error in "<<program_name<<": HMMER format not allowed as input due to the severe loss of sensitivity!\n"; exit(1); } // Is infile a HMMER3 file? if (!strncmp(line,"HMMER3",6)) { if (v>=2) cout<<"Query file is in HMMER3 format\n"; // Read 'query HMMER file rewind(inf); q.ReadHMMer3(inf,path); // Don't add transition pseudocounts to query!! // DON'T ADD amino acid pseudocounts to query: pcm=0! q.p[i][a] = f[i][a] q.AddAminoAcidPseudocounts(0, par.pca, par.pcb, par.pcc); q.CalculateAminoAcidBackground(); } // ... or is infile an old HMMER file? else if (!strncmp(line,"HMMER",5)) { if (v>=2) cout<<"Query file is in HMMER format\n"; // Read 'query HMMER file rewind(inf); q.ReadHMMer(inf,path); // DON'T ADD amino acid pseudocounts to query: pcm=0! q.p[i][a] = f[i][a] q.AddAminoAcidPseudocounts(0, par.pca, par.pcb, par.pcc); q.CalculateAminoAcidBackground(); } } else { cerr<<endl<<"Error in "<<program_name<<": unrecognized input file format in \'"<<infile<<"\'\n"; cerr<<"line = "<<line<<"\n"; exit(1); } fclose(inf); if (par.addss==1) CalculateSS(q); if (par.columnscore == 5 && !q.divided_by_local_bg_freqs) q.DivideBySqrtOfLocalBackgroundFreqs(par.half_window_size_local_aa_bg_freqs); if (par.forward>=1) q.Log2LinTransitionProbs(1.0); return; }
// Read input file (HMM, HHM, or alignment format), and add pseudocounts etc. void ReadInput(char* infile, HMM& q, Alignment* qali=NULL) { char path[NAMELEN]; // Open query file and determine file type char line[LINELEN]=""; // input line FILE* inf=NULL; if (strcmp(infile,"stdin")) { inf = fopen(infile, "r"); if (!inf) OpenFileError(infile); Pathname(path,infile); } else { inf = stdin; if (v>=2) printf("Reading HMM / multiple alignment from standard input ...\n(To get a help list instead, quit and type %s -h.)\n",program_name); *path='\0'; } fgetline(line,LINELEN-1,inf); // Is infile a HMMER3 file? if (!strncmp(line,"HMMER3",6)) { if (v>=2) cout<<"Query file is in HMMER3 format\n"; cerr<<"WARNING: Use of HMMER3 format as input will result in severe loss of sensitivity!\n"; // Read 'query HMMER file rewind(inf); q.ReadHMMer3(inf,path); } // ... or is infile an old HMMER file? else if (!strncmp(line,"HMMER",5)) { if (v>=2) cout<<"Query file is in HMMER format\n"; cerr<<"WARNING: Use of HMMER format as input will result in severe loss of sensitivity!\n"; // Read 'query HMMER file rewind(inf); q.ReadHMMer(inf,path); } // ... or is it an hhm file? else if (!strncmp(line,"NAME",4) || !strncmp(line,"HH",2)) { if (v>=2) cout<<"Query file is in HHM format\n"; // Rewind to beginning of line and read query hhm file rewind(inf); q.Read(inf,path); if (v>=2 && q.Neff_HMM>11.0) fprintf(stderr,"WARNING: HMM %s looks too diverse (Neff=%.1f>11). Better check the underlying alignment... \n",q.name,q.Neff_HMM); } // ... or is it an alignment file else { Alignment* pali; if (qali==NULL) pali=new(Alignment); else pali=qali; if (par.calibrate) { printf("\nError in %s: only HHM files can be calibrated.\n",program_name); printf("Build an HHM file from your alignment with 'hhmake -i %s' and rerun hhsearch with the hhm file\n\n",infile); exit(1); } if (v>=2 && strcmp(infile,"stdin")) cout<<infile<<" is in A2M, A3M or FASTA format\n"; // Read alignment from infile into matrix X[k][l] as ASCII (and supply first line as extra argument) pali->Read(inf,infile,line); // Convert ASCII to int (0-20),throw out all insert states, record their number in I[k][i] // and store marked sequences in name[k] and seq[k] pali->Compress(infile); // Sort out the nseqdis most dissimilar sequences for display in the output alignments pali->FilterForDisplay(par.max_seqid,par.coverage,par.qid,par.qsc,par.nseqdis); // Remove sequences with seq. identity larger than seqid percent (remove the shorter of two) pali->N_filtered = pali->Filter(par.max_seqid,par.coverage,par.qid,par.qsc,par.Ndiff); if (par.Neff>=0.999) pali->FilterNeff(); // Calculate pos-specific weights, AA frequencies and transitions -> f[i][a], tr[i][a] pali->FrequenciesAndTransitions(q); if (v>=2 && q.Neff_HMM>11.0) fprintf(stderr,"WARNING: alignment %s looks too diverse (Neff=%.1f>11). Better check it with an alignment viewer... \n",q.name,q.Neff_HMM); if (qali==NULL) delete(pali); } fclose(inf); return; }
///////////////////////////////////////////////////////////////////////////////////// //// MAIN PROGRAM ///////////////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { char* argv_conf[MAXOPT]; // Input arguments from .hhdefaults file (first=1: argv_conf[0] is not used) int argc_conf; // Number of arguments in argv_conf strcpy(par.infile, ""); strcpy(par.outfile, ""); strcpy(par.alnfile, ""); //Default parameter settings par.nseqdis = MAXSEQ - 1; // maximum number of sequences to be written par.showcons = 0; par.cons = 1; par.Ndiff = 0; par.max_seqid = 100; par.coverage = 0; par.pc_hhm_context_engine.pca = 0.0; // no amino acid pseudocounts par.pc_hhm_nocontext_a = 0.0; // no amino acid pseudocounts par.gapb = 0.0; // no transition pseudocounts // Make command line input globally available par.argv = argv; par.argc = argc; RemovePathAndExtension(program_name, argv[0]); // Enable changing verbose mode before defaults file and command line are processed int v = 2; for (int i = 1; i < argc; i++) { if (!strcmp(argv[i], "-def")) par.readdefaultsfile = 1; else if (strcmp(argv[i], "-v") == 0) { v = atoi(argv[i + 1]); } } par.v = Log::from_int(v); Log::reporting_level() = par.v; par.SetDefaultPaths(); // Read .hhdefaults file? if (par.readdefaultsfile) { // Process default otpions from .hhconfig file ReadDefaultsFile(argc_conf, argv_conf); ProcessArguments(argc_conf, argv_conf); } // Process command line options (they override defaults from .hhdefaults file) ProcessArguments(argc, argv); Alignment* qali = new Alignment(MAXSEQ, par.maxres); HMM* q = new HMM(MAXSEQDIS, par.maxres); //Create a HMM with maximum of par.maxres match states // q is only available after maxres is known, so we had to move this here for (int i = 1; i <= argc - 1; i++) { if (!strcmp(argv[i], "-name") && (i < argc - 1)) { strmcpy(q->name, argv[++i], NAMELEN - 1); //copy longname to name... strmcpy(q->longname, argv[i], DESCLEN - 1); //copy full name to longname } } // Check command line input and default values if (!*par.infile) { help(); HH_LOG(ERROR) << "Input file is missing!" << std::endl; exit(4); } // Get basename RemoveExtension(q->file, par.infile); //Get basename of infile (w/o extension): // Outfile not given? Name it basename.hhm if (!*par.outfile && !*par.alnfile) { RemoveExtension(par.outfile, par.infile); strcat(par.outfile, ".seq"); } // Prepare CS pseudocounts lib if (!par.nocontxt && *par.clusterfile) { InitializePseudocountsEngine(par, context_lib, crf, pc_hhm_context_engine, pc_hhm_context_mode, pc_prefilter_context_engine, pc_prefilter_context_mode); } // Set substitution matrix; adjust to query aa distribution if par.pcm==3 SetSubstitutionMatrix(par.matrix, pb, P, R, S, Sim); // Read input file (HMM, HHM, or alignment format), and add pseudocounts etc. char input_format = 0; ReadQueryFile(par, par.infile, input_format, par.wg, q, qali, pb, S, Sim); // Same code as in PrepareQueryHMM(par.infile,input_format,q,qali), except that we add SS prediction // Add Pseudocounts, if no HMMER input if (input_format == 0) { // Transform transition freqs to lin space if not already done q->AddTransitionPseudocounts(par.gapd, par.gape, par.gapf, par.gapg, par.gaph, par.gapi, par.gapb, par.gapb); // Comput substitution matrix pseudocounts if (par.nocontxt) { // Generate an amino acid frequency matrix from f[i][a] with full pseudocount admixture (tau=1) -> g[i][a] q->PreparePseudocounts(R); // Add amino acid pseudocounts to query: p[i][a] = (1-tau)*f[i][a] + tau*g[i][a] q->AddAminoAcidPseudocounts(par.pc_hhm_nocontext_mode, par.pc_hhm_nocontext_a, par.pc_hhm_nocontext_b, par.pc_hhm_nocontext_c); } else { // Add full context specific pseudocounts to query q->AddContextSpecificPseudocounts(pc_hhm_context_engine, pc_hhm_context_mode); } } else { q->AddAminoAcidPseudocounts(0, par.pc_hhm_nocontext_a, par.pc_hhm_nocontext_b, par.pc_hhm_nocontext_c); } q->CalculateAminoAcidBackground(pb); if (par.columnscore == 5 && !q->divided_by_local_bg_freqs) q->DivideBySqrtOfLocalBackgroundFreqs( par.half_window_size_local_aa_bg_freqs, pb); // Write consensus sequence to sequence file // Consensus sequence is calculated in hhalignment.C, Alignment::FrequenciesAndTransitions() if (*par.outfile) { FILE* outf = NULL; if (strcmp(par.outfile, "stdout")) { outf = fopen(par.outfile, "a"); if (!outf) OpenFileError(par.outfile, __FILE__, __LINE__, __func__); } else outf = stdout; // OLD //// ">name_consensus" -> ">name consensus" //strsubst(q->sname[q->nfirst],"_consensus"," consensus"); //fprintf(outf,">%s\n%s\n",q->sname[q->nfirst],q->seq[q->nfirst]+1); // NEW (long header needed for NR30cons database) fprintf(outf, ">%s\n%s\n", q->longname, q->seq[q->nfirst] + 1); fclose(outf); } // Print A3M/A2M/FASTA output alignment if (*par.alnfile) { HalfAlignment qa; int n = imin(q->n_display, par.nseqdis + (q->nss_dssp >= 0) + (q->nss_pred >= 0) + (q->nss_conf >= 0) + (q->ncons >= 0)); qa.Set(q->name, q->seq, q->sname, n, q->L, q->nss_dssp, q->nss_pred, q->nss_conf, q->nsa_dssp, q->ncons); if (par.outformat == 1) qa.BuildFASTA(); else if (par.outformat == 2) qa.BuildA2M(); else if (par.outformat == 3) qa.BuildA3M(); if (qali->readCommentLine) qa.Print(par.alnfile, par.append, qali->longname); // print alignment to outfile else qa.Print(par.alnfile, par.append); // print alignment to outfile } delete qali; delete q; DeletePseudocountsEngine(context_lib, crf, pc_hhm_context_engine, pc_hhm_context_mode, pc_prefilter_context_engine, pc_prefilter_context_mode); }