3
$\begingroup$

I have some fragments of DNA from single and double digests using three different restriction enzymes. I'm trying to construct a restriction map of a linear fragment of DNA. The map needs indicate the relative positions of the restriction sites along with distances from the ends.

Can this be done using python at all?

DNA Sizes of Fragments (bp) - uncut DNA = 900

DNA cut with EcoRI = 500, 350, 50

DNA cut with HindIII = 600, 300

DNA cut with BamHI = 400, 300, 200

DNA cut with EcoRI + HindIII = 350, 300, 200, 50

DNA cut with EcoRI + BamHI = 300, 250, 200, 100, 50

DNA cut with HindIII + BamHI = 300, 200, 100

$\endgroup$
3
  • $\begingroup$ I've updated the description so hopefully it is more clearer $\endgroup$ Commented Mar 3, 2016 at 15:53
  • $\begingroup$ Perhaps pointing in the right direction? Like where to find possible modules that do this? We're not all experts. $\endgroup$ Commented Mar 3, 2016 at 18:26
  • $\begingroup$ I'm voting to close this question as off-topic because this is about programming in python and not really about biology or bioinformatics. $\endgroup$
    – WYSIWYG
    Commented Mar 4, 2016 at 5:46

2 Answers 2

3
$\begingroup$

I agree with the previous answer. You can certainly write a solution in python, but have to formulate it as an algorithm first. Doing so will enable us to suggest an actual solution.

Also, I wanted to suggest that posting this questions on a forum with bioinformatics focus (biostars.org) may yield better feedback.

$\endgroup$
3
$\begingroup$

First I'll answer this question on the assumption that you are learning or about to learn python (perhaps because you have heard it's become popular in bioinformatics) and you wish to know whether it can be applied to this problem. The answer is: almost certainly, yes. Python is a programming language of the type that can be used to automate the solution of this sort of problem, just as C, C++, Java, Perl could.

How would you go about it? You would first solve the problem by hand, analyse the logic of your solution and then try to devise a general algorithm based on this logic that can deal with a variety of cases. Then you would code this in python (or whatever). The program would have to deal with inaccuracies in real values of fragment lengths (your data are obviously contrived) and the possibility of more than one fragment of the same length (see below). If you used python and wanted graphic output you would need to use a library that provides graphics as python does not come with graphics like Java does. I gather there are some. However this is certainly not the easiest of programming tasks for a beginner, as you'll see when you try to analyse the logic of manual solution. And of course the data might be insufficient to provide a unique solution.

However as this is a homework assignment you may also be wanting to find a program to check your answer and perhaps be unsure of how to go about it. I don't know of any packages to do this — it's perhaps not 'cutting edge'. So how to go about it?

What I would do is start with the single digests and draw a set of diagrams for each of the possible arrangements of the restriction sites in each case (pencil and paper work well here). Then I'd look at the simplest double-digest, identify unique fragments that were also present in the single digests and thus not cut by the second enzyme, and again draw diagrams of the possibilities for the pairs of restrictions sites. Be careful; the HindIII/BamHI double-digest doesn't add up to 900, so there must be two fragments of the same size here. When you have all the possibilities drawn out, there is presumably only one final restriction diagram that is consistent with all the data.

On second thoughts, devising an algorithm for solving this general case would be quite a demanding task. If you are starting programming I'd tackle easier algorithms first. And an effective algorithm might adopt a brute force approach rather than the semi-intuitive way we solve these by hand. For example your algorithm might generate all possible maps for each of the the three single digestions, and then generate all possible maps for the double-digestions, together with a calculation of the size of fragments the double-digestions would generate. These would be compared with the size of the actual fragments from double-digestions, eliminating those possibilities that don't fit. Coding it would involve writing methods/functions (or whatever they are called in python) to generate these maps, storing the coordinates of the sites in a data structure such as an array, and writing other methods to make comparisons etc.

$\endgroup$
4
  • $\begingroup$ Thanks for the advice David. It was a homework assignment and I did manage to figure it out. My inquiry to whether it was possible using python is one of interest as I've just started learning it $\endgroup$ Commented Mar 4, 2016 at 19:44
  • $\begingroup$ OK. I'll edit my answer to take account of that. $\endgroup$
    – David
    Commented Mar 4, 2016 at 22:15
  • $\begingroup$ Python has good string functions, as do Java and C++. You could make a list of restriction enzymes, probably a map or hashmap. Then you load your DNA sequence as a string and iterate through the list of enzymes, searching for the restriction site in the DNA string, and returning the position of the site in the DNA sequence. If the strings do not match, a -1 will be returned. So if you just want a list, you can print to console or a text file. If you want an image, you need to make a list of restriction sites, with enzyme type and cut location, then use pygame or something to draw the map. $\endgroup$
    – user137
    Commented Mar 5, 2016 at 5:20
  • $\begingroup$ Drawing the map isn't hard either. If linear, the DNA of B bases is a line of P pixels long. So the restriction site at position b is drawn at pixel p where p = P * b/B. When circular, you'll need to calculate the pixel from an angle, where the angle is 360 * b/B. $\endgroup$
    – user137
    Commented Mar 5, 2016 at 5:23

Not the answer you're looking for? Browse other questions tagged .