This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Is There A Method Or Script To Read Distance Matrix Output Using Python

Hello,

I am looking for a biopython method or regular python script to read in distance matrix output from EMBOSS program distmat (http://emboss.sourceforge.net/apps/release/6.4/emboss/apps/distmat.html) . I have searched but found nothing.

Thanks!

python biopython distance

1 answer

From looking at the sample output of distmat it looks like a - hopefully - tab separated format, so it is maybe not required to use biopython. I guess what you could do is

  • skip the few header lines
  • use string split using "t" on each line and read this into a vector or array data structure. Names seem to be the last column in each line.

From the example output though it could also be a format which uses variable number of space spaces to align the ouput columns, this would make things slightly more difficult but not impossible. In this case, you had to split by "s+" (multiple spaces) and fill up each row vector with #n undefined values, according to the #n the line number (starting at 0).

As you might have noticed, I don't know python, but I'm sure it has something like a split and arrays (as people still claim it is nearly as powerful as perl xD). If that doesn't seem to help, ignore this answer or ask me for a perl script.

Thanks Michael. I had similar thoughts just throughout I would check if there is an existing way...

Log in to answer this question.