AlnBlock * Align_strings_ProteinSmithWaterman(char * one,char * two,CompMat * comp,int gap,int ext,DPRunImpl * dpri) { Sequence * one_s; Sequence * two_s; AlnBlock * out; /* error check the strings? */ one_s = new_Sequence_from_strings(NULL,one); if( one_s == NULL ) { warn("Cannot make new sequence...\n"); return NULL; } two_s = new_Sequence_from_strings(NULL,two); if( two_s == NULL ) { warn("Cannot make new sequence...\n"); return NULL; } out = Align_Sequences_ProteinSmithWaterman(one_s,two_s,comp,gap,ext,dpri); free_Sequence(one_s); free_Sequence(two_s); return out; }
int main(int argc,char ** argv) { AlignGeneModelParam * agmp; SeqAlign * sal; Sequence * seq; CompProb * cp; CodonTable * ct; DnaProbMatrix * dm; dm = DnaProbMatrix_from_match(0.8,NMaskType_VARIABLE); ct = read_CodonTable_file("codon.table"); cp = read_Blast_file_CompProb("wag85"); sal = SeqAlign_alloc_std(); seq = new_Sequence_from_strings("new1","ATGGGG"); add_SeqAlign(sal,seq); seq = new_Sequence_from_strings("new2","ATGGGT"); add_SeqAlign(sal,seq); agmp = std_AlignGeneModelParam(cp,dm,ct); printf("Codon 1 %f vs %f Codon 2 %f v %f \n", coding_probability_AlignGeneModel(sal,2,agmp), non_coding_probability_AlignGeneModel(sal,2,agmp), coding_probability_AlignGeneModel(sal,5,agmp), non_coding_probability_AlignGeneModel(sal,5,agmp) ); }
Sequence * swapped_Sequence(Sequence * reference,HitList * hl) { Sequence * out; int i; AlnColumn * alc; char buffer[512]; char * swapped; int coord; int swap; sprintf(buffer,"swapped_%s",reference->name); out = new_Sequence_from_strings(buffer,reference->seq); for(i=0;i<reference->len;i++) { out->seq[i] = tolower(reference->seq[i]); } /* calloc sets things to 0 be defn */ swapped = calloc(reference->len,sizeof(char)); for(i=0;i<hl->len;i++) { fprintf(stderr,"Using... %s\n",hl->pair[i]->target->name); for(alc =hl->pair[i]->aln[0]->alb->start ;alc != NULL;alc = alc->next) { /* fprintf(stderr," Looking at %d,%d\n",alc->alu[0]->end,alc->alu[1]->end);*/ if( strcmp(alc->alu[0]->text_label,"SEQUENCE") == 0 && strcmp(alc->alu[1]->text_label,"SEQUENCE") == 0 ) { /* fprintf(stderr,"MATCH Looking at %d,%d\n",alc->alu[0]->end,alc->alu[1]->end); */ coord = alc->alu[0]->end; swap = hl->pair[i]->target->seq[alc->alu[1]->end]; if( swapped[coord] == 1 ) { warn("Reswapping position %d to %c from %c",coord,swap,out->seq[coord]); } else if( toupper(swap) != toupper(out->seq[coord]) ) { info("Swapping position %d from %c to %c",coord,out->seq[coord],swap); } out->seq[coord] = toupper(swap); swapped[coord] = 1; } } } ckfree(swapped); return out; }
static Wise2HSP_HSP_ts_iterator impl_Wise2HSP_HSPmanagerFactory_scan_query_iterator(impl_POA_Wise2HSP_HSPmanagerFactory * servant, Wise2HSP_Sequence * query,CORBA_short max_size, CORBA_Environment * ev) { Wise2HSP_HSP_ts_iterator retval; Wise2HSP_HSPmanager* corba_hspm; Wise2_Sequence * wise2_seq; LinearHSPmanager * lm; HSPScanInterfacePara para; int size; int i; if( servant->is_verbose == 1 ) { fprintf(stdout,"going to do %s\n",query->name); } wise2_seq = new_Sequence_from_strings(query->name,query->seq); para.max_results = max_size; lm = (*servant->hsi->scan_query)(servant->hsi->data,wise2_seq,¶); /* fprintf(stderr,"Sanity check in corba\n"); for(i=0;i<lm->len;i++) { fprintf(stderr,"Got %s %d\n",lm->set[i]->hsp[0]->target->name,i); } */ if( servant->is_verbose == 1 ) { fprintf(stdout," ... retrieved HSP manager size %d\n",lm->len); } if( servant->is_verbose == 1 ) { fprintf(stdout," ... remapped HSP manager\n"); } if( servant->is_verbose == 1 ) { fprintf(stdout," ... freed data, about to return iterator\n"); } retval = impl_Wise2HSP_HSP_ts_iterator__create(servant->poa,lm,max_size,ev); return retval; }
static Wise2HSP_HSPmanager* impl_Wise2HSP_HSPmanagerFactory_scan_query(impl_POA_Wise2HSP_HSPmanagerFactory *servant, Wise2HSP_Sequence* query, CORBA_Environment *ev) { Wise2HSP_HSPmanager* retval; Wise2_Sequence * wise2_seq; LinearHSPmanager * lm; HSPScanInterfacePara para; int size; if( servant->is_verbose == 1 ) { fprintf(stdout,"going to do %s\n",query->name); } wise2_seq = new_Sequence_from_strings(query->name,query->seq); para.max_results = 250; lm = (*servant->hsi->scan_query)(servant->hsi->data,wise2_seq,¶); retval = corba_manager_from_wise_manager(lm); if( servant->is_verbose == 1 ) { fprintf(stdout," ... remapped HSP manager\n"); } Wise2_free_LinearHSPmanager(lm); if( servant->is_verbose == 1 ) { fprintf(stdout," ... freed data, about to return\n"); } return retval; }
ErrorSequence * make_ErrorSequence(Sequence * seq,Probability subs,Probability insertion,Probability deletion) { ErrorSequence * out; char * seq_buffer; int buf_len; int i,j; double rnd; char c[2]; SequenceError * se; i=j=0; out = ErrorSequence_alloc(); out->ses = SequenceErrorSet_alloc_std(); c[1] = '\0'; buf_len = seq->len *3; seq_buffer = (char*)calloc(buf_len,sizeof(char)); for(i=0;i<seq->len;i++) { if( j >= buf_len ) { warn("run out of temporary buffer in error sequence"); break; } rnd = random_0_to_1(); if( rnd > deletion ) { /* yes this base is here */ rnd = random_0_to_1(); if( rnd < subs ) { rnd = random_0_to_1(); if( rnd < 0.25 ) { c[0] = 'A'; } else if ( rnd < 0.5 ) { c[0] = 'T'; } else if ( rnd < 0.75 ) { c[0] = 'G'; } else { c[0] = 'C'; } se = SequenceError_alloc(); se->type = SeqErrorSubstitution; se->start = j+1; se->end = j+1; se->replaced_bases = stringalloc(c); add_SequenceErrorSet(out->ses,se); seq_buffer[j++] = c[0]; } else { seq_buffer[j++] = seq->seq[i]; } } else { /* there has been a deletion */ se = SequenceError_alloc(); se->type = SeqErrorDeletion; se->start = j+1; se->end = j+1; c[0] = seq_buffer[i]; se->suspected_deletion = stringalloc(c); add_SequenceErrorSet(out->ses,se); } rnd = random_0_to_1(); if( rnd < insertion ) { rnd = random_0_to_1(); if( rnd < 0.25 ) { c[0] = 'A'; } else if ( rnd < 0.5 ) { c[0] = 'T'; } else if ( rnd < 0.75 ) { c[0] = 'G'; } else { c[0] = 'C'; } se = SequenceError_alloc(); se->type = SeqErrorInsertion; se->start = j+1; se->end = j+1; se->inserted_bases = stringalloc(c); add_SequenceErrorSet(out->ses,se); seq_buffer[j++] = c[0]; } } seq_buffer[j] = '\0'; out->seq = new_Sequence_from_strings(seq->name,seq_buffer); return out; }