Biostrings C interface :: example not compiling
2
0
Entering edit mode
Erik Wright ▴ 210
@erik-wright-4003
Last seen 10.2 years ago
Hello all, I am trying to interface Biostrings from C for the first time. I followed the example given in the header of Biostrings_interface.h to the letter (quite literally). In step "e" I paste the example function into myFile.c, register it as a .Call entry point and compile with R CMD CHECK. I get the following errors: myFile.c:13: warning: implicit declaration of function ‘cache_XRaw’ myFile.c:13: error: incompatible types in assignment myFile.c:14: error: ‘cachedCharSeq’ has no member named ‘elts’ myFile.c:14: error: ‘cachedCharSeq’ has no member named ‘nelt’ Based on the error, it seems like I still don't have access to any of the Biostrings variable definitions. I have tried everything that I can think of, so I am quite stuck. Does anyone know what I am doing incorrectly? I have pasted myFile.c below for reference. Thanks!, Erik //myFile.c #include <rdefines.h> #include <r_ext rdynload.h=""> #include <stdio.h> #include <stdlib.h> #include "Biostrings_interface.h" SEXP print_XString_bytes(SEXP xstring) { cachedCharSeq x; int i; const char *x_char; x = cache_XRaw(xstring); for (i = 0, x_char = x.elts; i < x.nelt; i++, x_char++) Rprintf("%x ", *x_char); Rprintf("\n"); return R_NilValue; } /* * -- REGISTRATION OF THE .Call ENTRY POINTS --- */ static const R_CallMethodDef callMethods[] = { {"print_XString_bytes", (DL_FUNC) &print_XString_bytes, 1}, {NULL, NULL, 0} }; void R_init_GoneFISHing(DllInfo *info) { R_registerRoutines(info, NULL, callMethods, NULL, NULL); } [[alternative HTML version deleted]]
Biostrings Biostrings • 1.4k views
ADD COMMENT
0
Entering edit mode
Erik Wright ▴ 210
@erik-wright-4003
Last seen 10.2 years ago
Hello again, It looks like my problem is that the function listed in the example code, "cache_XRaw()", is deprecated. Is there any source of information about how to use the functions listed in Biostrings_interface.h? Thanks again, Erik On Apr 2, 2010, at 11:00 AM, Erik Wright wrote: > Hello all, > > I am trying to interface Biostrings from C for the first time. I followed the example given in the header of Biostrings_interface.h to the letter (quite literally). In step "e" I paste the example function into myFile.c, register it as a .Call entry point and compile with R CMD CHECK. I get the following errors: > > myFile.c:13: warning: implicit declaration of function ?cache_XRaw? > myFile.c:13: error: incompatible types in assignment > myFile.c:14: error: ?cachedCharSeq? has no member named ?elts? > myFile.c:14: error: ?cachedCharSeq? has no member named ?nelt? > > Based on the error, it seems like I still don't have access to any of the Biostrings variable definitions. I have tried everything that I can think of, so I am quite stuck. Does anyone know what I am doing incorrectly? I have pasted myFile.c below for reference. > > Thanks!, > Erik > > > > > //myFile.c > > #include <rdefines.h> > #include <r_ext rdynload.h=""> > #include <stdio.h> > #include <stdlib.h> > #include "Biostrings_interface.h" > > SEXP print_XString_bytes(SEXP xstring) > { > cachedCharSeq x; > int i; > const char *x_char; > > x = cache_XRaw(xstring); > for (i = 0, x_char = x.elts; i < x.nelt; i++, x_char++) > Rprintf("%x ", *x_char); > Rprintf("\n"); > return R_NilValue; > } > > /* > * -- REGISTRATION OF THE .Call ENTRY POINTS --- > */ > static const R_CallMethodDef callMethods[] = { > {"print_XString_bytes", (DL_FUNC) &print_XString_bytes, 1}, > {NULL, NULL, 0} > }; > > void R_init_GoneFISHing(DllInfo *info) > { > R_registerRoutines(info, NULL, callMethods, NULL, NULL); > } > [[alternative HTML version deleted]] > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
ADD COMMENT
0
Entering edit mode
Hi Erik, Erik Wright wrote: > Hello again, > > It looks like my problem is that the function listed in the example code, "cache_XRaw()", is deprecated. cache_XRaw() has been moved to the IRanges package a long time ago and has since then been part of the IRanges C interface. The example given in the header of Biostrings_interface.h needs to be updated to reflect this change. Thanks for catching this and sorry for the confusion. For your GoneFISHing package that means that you need to do steps a., b. and c. for both, Biostrings and IRanges. For step d., add: #include "IRanges_interface.h" just before #include "Biostrings_interface.h" Then try to compile again and let me know if that still doesn't work. > Is there any source of information about how to use the functions listed in Biostrings_interface.h? There is nothing like that and no plans at the moment to formally document the C-level interfaces. For now the best way to learn about these functions is to see how they are used in IRanges/Biostrings themselves (they are prefixed with an underscore when they are used from within the package where they are defined). The authors have made some efforts to use consistent naming, and, I think, a clean and consistent C coding style across the 2 packages so hopefully the code is not too hard to understand (some parts of the code are tricky but most are not). They will be happy to help you with any specific questions you have. Cheers, H. > > Thanks again, > Erik > > > > On Apr 2, 2010, at 11:00 AM, Erik Wright wrote: > >> Hello all, >> >> I am trying to interface Biostrings from C for the first time. I followed the example given in the header of Biostrings_interface.h to the letter (quite literally). In step "e" I paste the example function into myFile.c, register it as a .Call entry point and compile with R CMD CHECK. I get the following errors: >> >> myFile.c:13: warning: implicit declaration of function ?cache_XRaw? >> myFile.c:13: error: incompatible types in assignment >> myFile.c:14: error: ?cachedCharSeq? has no member named ?elts? >> myFile.c:14: error: ?cachedCharSeq? has no member named ?nelt? >> >> Based on the error, it seems like I still don't have access to any of the Biostrings variable definitions. I have tried everything that I can think of, so I am quite stuck. Does anyone know what I am doing incorrectly? I have pasted myFile.c below for reference. >> >> Thanks!, >> Erik >> >> >> >> >> //myFile.c >> >> #include <rdefines.h> >> #include <r_ext rdynload.h=""> >> #include <stdio.h> >> #include <stdlib.h> >> #include "Biostrings_interface.h" >> >> SEXP print_XString_bytes(SEXP xstring) >> { >> cachedCharSeq x; >> int i; >> const char *x_char; >> >> x = cache_XRaw(xstring); >> for (i = 0, x_char = x.elts; i < x.nelt; i++, x_char++) >> Rprintf("%x ", *x_char); >> Rprintf("\n"); >> return R_NilValue; >> } >> >> /* >> * -- REGISTRATION OF THE .Call ENTRY POINTS --- >> */ >> static const R_CallMethodDef callMethods[] = { >> {"print_XString_bytes", (DL_FUNC) &print_XString_bytes, 1}, >> {NULL, NULL, 0} >> }; >> >> void R_init_GoneFISHing(DllInfo *info) >> { >> R_registerRoutines(info, NULL, callMethods, NULL, NULL); >> } >> [[alternative HTML version deleted]] >> >> _______________________________________________ >> Bioconductor mailing list >> Bioconductor at stat.math.ethz.ch >> https://stat.ethz.ch/mailman/listinfo/bioconductor >> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor -- Hervé Pagès Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M2-B876 P.O. Box 19024 Seattle, WA 98109-1024 E-mail: hpages at fhcrc.org Phone: (206) 667-5791 Fax: (206) 667-1319
ADD REPLY
0
Entering edit mode
Hi Herv? & Chuck, Thanks for the help to get me started with the C interface. I have eventually figured out how to get the example working with functions in the Biostrings interface rather than the IR_Ranges interface: SEXP print_XString_bytes(SEXP x) { cachedXStringSet x_set; cachedCharSeq x_i; int i, j, x_length; x_set = cache_XStringSet(x); // number of XStrings in the XStringSet x_length = get_cachedXStringSet_length(&x_set); for (i = 0; i < x_length; i++) { // extract XString i from the XStringSet x_i = get_cachedXStringSet_elt(&x_set, i); // print each character along the XString for (j = 0; j < x_i.length; j++) Rprintf("%c", DNAdecode(x_i.seq[j])); Rprintf("\n"); } return R_NilValue; } Cheers, Erik On Apr 5, 2010, at 1:39 AM, Hervé Pagès wrote: > Hi Erik, > > Erik Wright wrote: >> Hello again, >> It looks like my problem is that the function listed in the example code, "cache_XRaw()", is deprecated. > > cache_XRaw() has been moved to the IRanges package a long time ago > and has since then been part of the IRanges C interface. The example > given in the header of Biostrings_interface.h needs to be updated to > reflect this change. Thanks for catching this and sorry for the > confusion. > > For your GoneFISHing package that means that you need to do steps a., > b. and c. for both, Biostrings and IRanges. For step d., add: > > #include "IRanges_interface.h" > > just before > > #include "Biostrings_interface.h" > > Then try to compile again and let me know if that still doesn't work. > >> Is there any source of information about how to use the functions listed in Biostrings_interface.h? > > There is nothing like that and no plans at the moment to formally > document the C-level interfaces. For now the best way to learn > about these functions is to see how they are used in > IRanges/Biostrings themselves (they are prefixed with an > underscore when they are used from within the package where > they are defined). The authors have made some efforts to use consistent > naming, and, I think, a clean and consistent C coding style across > the 2 packages so hopefully the code is not too hard to understand > (some parts of the code are tricky but most are not). They will be > happy to help you with any specific questions you have. > > Cheers, > H. > >> Thanks again, >> Erik >> On Apr 2, 2010, at 11:00 AM, Erik Wright wrote: >>> Hello all, >>> >>> I am trying to interface Biostrings from C for the first time. I followed the example given in the header of Biostrings_interface.h to the letter (quite literally). In step "e" I paste the example function into myFile.c, register it as a .Call entry point and compile with R CMD CHECK. I get the following errors: >>> >>> myFile.c:13: warning: implicit declaration of function ?cache_XRaw? >>> myFile.c:13: error: incompatible types in assignment >>> myFile.c:14: error: ?cachedCharSeq? has no member named ?elts? >>> myFile.c:14: error: ?cachedCharSeq? has no member named ?nelt? >>> >>> Based on the error, it seems like I still don't have access to any of the Biostrings variable definitions. I have tried everything that I can think of, so I am quite stuck. Does anyone know what I am doing incorrectly? I have pasted myFile.c below for reference. >>> >>> Thanks!, >>> Erik >>> >>> >>> >>> >>> //myFile.c >>> >>> #include <rdefines.h> >>> #include <r_ext rdynload.h=""> >>> #include <stdio.h> >>> #include <stdlib.h> >>> #include "Biostrings_interface.h" >>> >>> SEXP print_XString_bytes(SEXP xstring) >>> { >>> cachedCharSeq x; >>> int i; >>> const char *x_char; >>> >>> x = cache_XRaw(xstring); >>> for (i = 0, x_char = x.elts; i < x.nelt; i++, x_char++) >>> Rprintf("%x ", *x_char); >>> Rprintf("\n"); >>> return R_NilValue; >>> } >>> >>> /* >>> * -- REGISTRATION OF THE .Call ENTRY POINTS --- >>> */ >>> static const R_CallMethodDef callMethods[] = { >>> {"print_XString_bytes", (DL_FUNC) &print_XString_bytes, 1}, >>> {NULL, NULL, 0} >>> }; >>> >>> void R_init_GoneFISHing(DllInfo *info) >>> { >>> R_registerRoutines(info, NULL, callMethods, NULL, NULL); >>> } >>> [[alternative HTML version deleted]] >>> >>> _______________________________________________ >>> Bioconductor mailing list >>> Bioconductor at stat.math.ethz.ch >>> https://stat.ethz.ch/mailman/listinfo/bioconductor >>> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor >> _______________________________________________ >> Bioconductor mailing list >> Bioconductor at stat.math.ethz.ch >> https://stat.ethz.ch/mailman/listinfo/bioconductor >> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > > -- > Hervé Pagès > > Program in Computational Biology > Division of Public Health Sciences > Fred Hutchinson Cancer Research Center > 1100 Fairview Ave. N, M2-B876 > P.O. Box 19024 > Seattle, WA 98109-1024 > > E-mail: hpages at fhcrc.org > Phone: (206) 667-5791 > Fax: (206) 667-1319
ADD REPLY
0
Entering edit mode
Hi Erik, Erik Wright wrote: > Hi Herv? & Chuck, > > Thanks for the help to get me started with the C interface. > > I have eventually figured out how to get the example working with functions in the Biostrings interface rather than the IR_Ranges interface: > > SEXP print_XString_bytes(SEXP x) > { > cachedXStringSet x_set; > cachedCharSeq x_i; > int i, j, x_length; > > x_set = cache_XStringSet(x); > > // number of XStrings in the XStringSet > x_length = get_cachedXStringSet_length(&x_set); > > for (i = 0; i < x_length; i++) { > // extract XString i from the XStringSet > x_i = get_cachedXStringSet_elt(&x_set, i); > > // print each character along the XString > for (j = 0; j < x_i.length; j++) > Rprintf("%c", DNAdecode(x_i.seq[j])); > > Rprintf("\n"); > } > return R_NilValue; > } That's indeed the right way to "walk" on an XStringSet object at the C level. Glad your figured it out! H. > > Cheers, > Erik > > > > > On Apr 5, 2010, at 1:39 AM, Hervé Pagès wrote: > >> Hi Erik, >> >> Erik Wright wrote: >>> Hello again, >>> It looks like my problem is that the function listed in the example code, "cache_XRaw()", is deprecated. >> cache_XRaw() has been moved to the IRanges package a long time ago >> and has since then been part of the IRanges C interface. The example >> given in the header of Biostrings_interface.h needs to be updated to >> reflect this change. Thanks for catching this and sorry for the >> confusion. >> >> For your GoneFISHing package that means that you need to do steps a., >> b. and c. for both, Biostrings and IRanges. For step d., add: >> >> #include "IRanges_interface.h" >> >> just before >> >> #include "Biostrings_interface.h" >> >> Then try to compile again and let me know if that still doesn't work. >> >>> Is there any source of information about how to use the functions listed in Biostrings_interface.h? >> There is nothing like that and no plans at the moment to formally >> document the C-level interfaces. For now the best way to learn >> about these functions is to see how they are used in >> IRanges/Biostrings themselves (they are prefixed with an >> underscore when they are used from within the package where >> they are defined). The authors have made some efforts to use consistent >> naming, and, I think, a clean and consistent C coding style across >> the 2 packages so hopefully the code is not too hard to understand >> (some parts of the code are tricky but most are not). They will be >> happy to help you with any specific questions you have. >> >> Cheers, >> H. >> >>> Thanks again, >>> Erik >>> On Apr 2, 2010, at 11:00 AM, Erik Wright wrote: >>>> Hello all, >>>> >>>> I am trying to interface Biostrings from C for the first time. I followed the example given in the header of Biostrings_interface.h to the letter (quite literally). In step "e" I paste the example function into myFile.c, register it as a .Call entry point and compile with R CMD CHECK. I get the following errors: >>>> >>>> myFile.c:13: warning: implicit declaration of function ?cache_XRaw? >>>> myFile.c:13: error: incompatible types in assignment >>>> myFile.c:14: error: ?cachedCharSeq? has no member named ?elts? >>>> myFile.c:14: error: ?cachedCharSeq? has no member named ?nelt? >>>> >>>> Based on the error, it seems like I still don't have access to any of the Biostrings variable definitions. I have tried everything that I can think of, so I am quite stuck. Does anyone know what I am doing incorrectly? I have pasted myFile.c below for reference. >>>> >>>> Thanks!, >>>> Erik >>>> >>>> >>>> >>>> >>>> //myFile.c >>>> >>>> #include <rdefines.h> >>>> #include <r_ext rdynload.h=""> >>>> #include <stdio.h> >>>> #include <stdlib.h> >>>> #include "Biostrings_interface.h" >>>> >>>> SEXP print_XString_bytes(SEXP xstring) >>>> { >>>> cachedCharSeq x; >>>> int i; >>>> const char *x_char; >>>> >>>> x = cache_XRaw(xstring); >>>> for (i = 0, x_char = x.elts; i < x.nelt; i++, x_char++) >>>> Rprintf("%x ", *x_char); >>>> Rprintf("\n"); >>>> return R_NilValue; >>>> } >>>> >>>> /* >>>> * -- REGISTRATION OF THE .Call ENTRY POINTS --- >>>> */ >>>> static const R_CallMethodDef callMethods[] = { >>>> {"print_XString_bytes", (DL_FUNC) &print_XString_bytes, 1}, >>>> {NULL, NULL, 0} >>>> }; >>>> >>>> void R_init_GoneFISHing(DllInfo *info) >>>> { >>>> R_registerRoutines(info, NULL, callMethods, NULL, NULL); >>>> } >>>> [[alternative HTML version deleted]] >>>> >>>> _______________________________________________ >>>> Bioconductor mailing list >>>> Bioconductor at stat.math.ethz.ch >>>> https://stat.ethz.ch/mailman/listinfo/bioconductor >>>> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor >>> _______________________________________________ >>> Bioconductor mailing list >>> Bioconductor at stat.math.ethz.ch >>> https://stat.ethz.ch/mailman/listinfo/bioconductor >>> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor >> -- >> Hervé Pagès >> >> Program in Computational Biology >> Division of Public Health Sciences >> Fred Hutchinson Cancer Research Center >> 1100 Fairview Ave. N, M2-B876 >> P.O. Box 19024 >> Seattle, WA 98109-1024 >> >> E-mail: hpages at fhcrc.org >> Phone: (206) 667-5791 >> Fax: (206) 667-1319 > -- Hervé Pagès Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M2-B876 P.O. Box 19024 Seattle, WA 98109-1024 E-mail: hpages at fhcrc.org Phone: (206) 667-5791 Fax: (206) 667-1319
ADD REPLY
0
Entering edit mode
Charles Berry ▴ 290
@charles-berry-5754
Last seen 5.7 years ago
United States
On Fri, 2 Apr 2010, Erik Wright wrote: > Hello all, > > I am trying to interface Biostrings from C for the first time. I > followed the example given in the header of Biostrings_interface.h to > the letter (quite literally). In step "e" I paste the example function > into myFile.c, register it as a .Call entry point and compile with R CMD > CHECK. I get the following errors: > > myFile.c:13: warning: implicit declaration of function ~Qcache_XRaw~R > myFile.c:13: error: incompatible types in assignment > myFile.c:14: error: ~QcachedCharSeq~R has no member named ~Qelts~R > myFile.c:14: error: ~QcachedCharSeq~R has no member named ~Qnelt~R > > Based on the error, it seems like I still don't have access to any of > the Biostrings variable definitions. I have tried everything that I can > think of, so I am quite stuck. Does anyone know what I am doing > incorrectly? I have pasted myFile.c below for reference. Erik, I have encountered difficulty getting cache_XRaw() to work myself, but last December I did get it to go. IIRC, putting together a standalone .so was a nightmare in which I ended up with hard coded paths and other hacks. I found the path of least resistance was to set up a package and have this: Depends: IRanges Imports: methods, IRanges LinkingTo: IRanges in the description file. (you get cache_XRaw from IRanges.) And I placed a file called IRanges_subs.c containing one-line: #include "_IRanges_stubs.c" in the src/ directory along with this .c file (beware line wrapping!): /* read some XRaw as integer */ #include <r.h> #include <rdefines.h> #include <r_ext error.h=""> #include <r_ext rdynload.h=""> #include "IRanges_interface.h" SEXP tryXRaw ( SEXP x ) { SEXP ans; int i,len; const char *x_char; cachedCharSeq X; X = cache_XRaw(x); for (i = 0, x_char = X.seq; i < X.length; i++, x_char++) Rprintf("%x ", *x_char); Rprintf("\n"); PROTECT( ans = NEW_INTEGER( X.length ) ); for (i = 0, x_char = X.seq; i < X.length; i++, x_char++) INTEGER(ans)[i]=X.seq[i]; UNPROTECT( 1); return ans; } R_CMethodDef cMethods[] = { {"tryXRaw", (DL_FUNC)&tryXRaw, 1, NULL}, {NULL,NULL, 0} }; void R_init_tryXRaw(DllInfo *dll) { R_registerRoutines(dll,cMethods,NULL,NULL,NULL); } /* end of file */ If this doesn't get you going I can build the package and send the tgz to you privately as .tgz HTH, Chuck p.s. In the course of researching how to get this going I encountered alphabetFrequency() which solved the problem I was planning to use cache_XRaw() for, so I never bothered to go any further. > > Thanks!, > Erik > > > > > //myFile.c > > #include <rdefines.h> > #include <r_ext rdynload.h=""> > #include <stdio.h> > #include <stdlib.h> > #include "Biostrings_interface.h" > > SEXP print_XString_bytes(SEXP xstring) > { > cachedCharSeq x; > int i; > const char *x_char; > > x = cache_XRaw(xstring); > for (i = 0, x_char = x.elts; i < x.nelt; i++, x_char++) > Rprintf("%x ", *x_char); > Rprintf("\n"); > return R_NilValue; > } > > /* > * -- REGISTRATION OF THE .Call ENTRY POINTS --- > */ > static const R_CallMethodDef callMethods[] = { > {"print_XString_bytes", (DL_FUNC) &print_XString_bytes, 1}, > {NULL, NULL, 0} > }; > > void R_init_GoneFISHing(DllInfo *info) > { > R_registerRoutines(info, NULL, callMethods, NULL, NULL); > } > [[alternative HTML version deleted]] > > > > [ Part 3.2: "Included Message" ] > Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry at tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
ADD COMMENT

Login before adding your answer.

Traffic: 761 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6