Question: How To Extract An Algorithm From A Visual Basic Software And Port It In Python?
gravatar for mariusorion
7.0 years ago by
mariusorion50 wrote:

Hi there,

I am trying to extract the base algorithm from a visual basic software, to port it in python or PHP. It seems simple in theory but I am not a professional programmer. I know python and a little PHP but I know very little about Visual Basic. I've tried to stick to visual basic but it seems that any changes I made to this software (PromKappa) damages the program. Can someone help me with a simpler version in python (or PHP)?

Any help is greatly appreciated, thanks!

genes sequence dna • 3.3k views
ADD COMMENTlink modified 7.0 years ago • written 7.0 years ago by mariusorion50

It seems to me you'd have to be able to write out the algorithm, so that you can port it to your language of choice. If you don't understand it enough to write it out (i.e. as in pseudo-code), you risk programming something that may give you a result, with no guarantee that it's the correct result. "Extracting the algorithm" means you could write it down for someone. Poking around with visual basic, with the goal of getting an output that doesn't break the program, sounds kind of scary. Better to take the time to understand what's going on, and avoid black boxes.

ADD REPLYlink written 7.0 years ago by seidel7.0k

Hi seidel,

Last night I read your comment and I stood a little to digest the problem. I need 3 functions: the first one (that I have from other experiments) should feed with sliding windows other two functions (one calculates Kappa and one calculates the CG content). Thus, each sliding window generates a point with the x=CG and y=kappa. If all goes well my code it should reach a very bizarre pattern, but that's just in theory for now.


ADD REPLYlink written 7.0 years ago by mariusorion50

The program you have linked seems to be very simple. Basically, it just calculates the GC content of a promoter region, and an index of coincidence, which I think is a sort of alignment score. Which part of this algorithm do you want to reproduce?

ADD REPLYlink written 7.0 years ago by Giovanni M Dall'Olio27k

Hi Giovanni,

That is the problem, that in theory is easy, but when I looked at PromKappa source code I remained "cross-eyed", it was too complicated. The software does much more than it is explained in the article and the source code does not have explanatory comments for each function or line of code. I originally wanted to cut the source code until only the section that interests me remains functional. The reason I want to port it is that the kappa index of coincidence is fundamentally different from sequence alignments (the analysis is done on a single sequence).


ADD REPLYlink written 7.0 years ago by mariusorion50

You need to edit this question to highlight the bioinformatics problem you are trying to solve. Right now it looks like a generic programming question.

ADD REPLYlink written 7.0 years ago by Neilfws48k

Hi Neilfws,

I try to make the simplified python version of this program, because I do not know visual basic. If my python implementation does not work in any way, I will make a new post here that will include my code in python for a direct advice on the code. The end result of my code must look something like this:


ADD REPLYlink modified 7.0 years ago • written 7.0 years ago by mariusorion50

Still sounds like a generic programming question :) Care to try again?

ADD REPLYlink written 7.0 years ago by Neilfws48k

I found the hard solution for PHP ...

ADD REPLYlink written 7.0 years ago by mariusorion50

Please look one minute at the software: I want to know which function handles kappa and the C + G. thanks.

I was not able to do much with the converter, for example this function:

Private Sub gene_search_Click()
pro_no = List_promotori.ListCount
For i = 0 To pro_no
If List_promotori.List(i) <> "" Then
    If InStr(UCase(List_promotori.List(i)), UCase(gene_search_txt.Text)) <> 0 Then
    a = List_promotori.ItemData(i)
    MsgBox "Item found in row no " & i
        List_promotori.Enabled = False
        secventata.Text = Split(List_promotori.List(i), "|")(1)
        seq_name_from_file.Caption = Split(List_promotori.List(i), "|")(0)
        List_promotori.Enabled = True
    Exit Sub
    End If
End If
Next i
MsgBox "Gene promoter not found !"
End Sub

is converted in:

def gene_search_Click():
    pro_no = List_promotori.ListCount
    for i in vbForRange(0, pro_no):
        if List_promotori.List(i) <> '':
            if InStr(UCase(List_promotori.List(i)), UCase(gene_search_txt.text)) <> 0:
                a = List_promotori.ItemData(i)
                MsgBox('Item found in row no ' + i)
                List_promotori.Enabled = False
                secventata.text = Split(List_promotori.List(i), '|')(1)
                seq_name_from_file.text = Split(List_promotori.List(i), '|')(0)
                List_promotori.Enabled = True
    MsgBox('Gene promoter not found !')

which really confused me even more :)

ADD REPLYlink modified 7.0 years ago • written 7.0 years ago by mariusorion50
gravatar for
7.0 years ago by
European Union wrote:

Hi, I never used automatic code converters, but sometime they provide a good starting point, here is a project for converting VB to python.

Anyway, even if the program is simple, be sure to setup a good testing-framework, to check that results remain the same.

Have luck !

ADD COMMENTlink written 7.0 years ago by


I tried the converter. If I feed the entire PromKappa source code to the converter, then a real mess comes out in python, but if I feed individual functions it works like a charm. Certainly this converter helps me, at least I am familiar with the code.


ADD REPLYlink written 7.0 years ago by mariusorion50
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1200 users visited in the last hour