Porting BioPython app to C# and .NET Bio

Aug 12, 2013 at 6:23 PM
Hi Folks

I'm looking at the possibility of porting an application from BioPython to .NET bio and C#. Are there any porting guides available? Or does anyone have any experience of doing this? I'd be interested in any opinions/views on the subject.

One of the main differences I've seen so far is in the alignment functionality. BioPython has a pairwise2 module which does not directly map to anything in .NET Bio (that I can find).

Thanks

Mark.
Coordinator
Aug 12, 2013 at 6:34 PM
I'm assuming the pairwise2 module is just a global/local aligner? There are 3 pairwise aligners in .NET Bio:

PairwiseOverlapAligner - performs a simple overlap pairwise alignment for two sequences
SmithWatermanAligner - performs a local alignment for two sequences
NeedlemanWunschAligner - performs a global alignment for two sequences

I'd guess the SmithWaterman and NeedlemanWunsch aligners are the two you want to use - pick the first for local and the second for global alignments. You can use the IPairwiseSequenceAligner interface to abstract it out in your code:

IPairwiseSequenceAligner pwa;
if (isLocal)
pwa = new NeedlemanWunschAligner();
else
pwa = new SmithWatermanAligner();

...

This should work essentially the same way as the pairwise2 aligner (I think) where you set a flag for local vs. global.

Does that help?

mark



Mark Smith

[email removed] | @marksm | 214-774-4749 | www.julmar.com/blog/mark



Developer
Aug 12, 2013 at 6:39 PM
Hi Mark,

I use the BioPython libraries in IronPython pretty frequently, mostly the I/O routines.

In general, my sense is everything should (and has so far) worked directly after appending the library location to the path, except for things which are coded as C extensions. I last used the pairwise alignment modules almost 8 years ago so can't speak to their current state, but at the time they offered two varieties, a python coded aligner which was too slow to be useful, and a C coded extension which ran into problems compiling, so the biopython library would fall back to the python code if the C wasn't available.

Mark just listed some of the aligners available in .NET bio, and I would probably go ahead and use those directly. They will be MUCH faster than the python code, and I would expect to be more feature rich to. Which module are you trying to port? If it depends heavily on the pairwise2 you could "wrap" our aligners to pose as the Biopython ones, or if you just need the alignments I would use the .NET Bio version directly.

Cheers,
N
Aug 13, 2013 at 1:46 PM
Thanks for the quick responses. In some test code I managed to get output with the SmithWatermanAligner that matched the output from the pairwise2 module in BioPython.

Thanks

Mark.