This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Extract An Algorithm From A Visual Basic Software And Port It In Python?

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 dna sequence

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.

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.

thanks.

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?

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).

thanks.

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.

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

Please look one minute at the software:http://www.biomedcentral.com/content/supplementary/1471-2164-13-512-s3.rar. 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)
        Procesare_Click
        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)
                Procesare_Click()
                List_promotori.Enabled = True
                return
    MsgBox('Gene promoter not found !')

which really confused me even more :)

1 answer

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 !

Hi ff.cc.cc,

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.

thanks.

Log in to answer this question.