0

I have a pretty odd question.

Via Python I create a .bed file. This .bed file consists of 3 columns: chromosomestartend. This file should then be analysed by a build-in tool in Linux, but it says "Unexpected file format.". Via cat -e file.bed | more I saw that all lines end with ^M$, where it should end with only $ (Atleast manually created files show only $ and work).

Does anyone know how to solve this? I'm using Bio-Linux on a VirtualBox with Ubuntu 12.04.4 LTS

Thanks,

Edit: File is build up in Python via;

test = "".join(chromosomes) #chromosomes = chr<tab>start<tab>end<space>\n
bed.write(test[0:-1])
Coryza
  • 231
  • 1
  • 3
  • 12
  • 2
    This should help you: http://stackoverflow.com/questions/3191289/how-to-remove-m – xsl Mar 12 '14 at 13:49
  • 1
    Windows-format text files end with `\r\n`, UNIX text files end with only `\n`. I'm guessing that you're generating this file on Windows. If you open your file for write in binary mode (`bed = open(outfile, 'wb')` -- the `b` being the key -- Python 2.x will stop trying to do the conversion to locally native newlines for you (which it's otherwise doing by adding the missing `\r` characters, which `cat -A` renders as `^M`). Of course, this will make some Windows programs (such as notepad) unhappy. – Charles Duffy Mar 12 '14 at 13:53
  • I'm gonna try tomorrow, but I assume my problem is solved. Thanks a lot all ;) – Coryza Mar 12 '14 at 18:43

0 Answers0