This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to sort PDB name

Hey guys,

So I have a file contains PDB ID and SEG signal regions. which looks like this:

1JCE  339 340 341 342 343 344
1RQE 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
1VRA  7 8 9 10 11 12  186 187 188 189 190 191 192 193 194 195 196 197 198 199
2H17  3 4 5 6 7 8 9 10 11 12
2WBY 2 3 4 5 6 7  255 256 257 258 259 260 261 262 263 264 265 266 267 268 269

So I would like to know how to sort the file so that PDBID appears in order. in this case they are in order. So I would like the order to be like first compare the first charter of the PDBID and then second and then third and then forth and form an order

How to I do that with python? I've tried to use sorted. But I'm still quit confused.

pdb python sort name

1 answer

Sorting a textfile (which is what you are dealing with) is a very basic and general problem. It's probably been asked before.. Yep:

http://stackoverflow.com/questions/3002392/sorting-content-of-a-text-file-in-python

If you're on mac os x or linux, just open a terminal and try

sort pdb_textfile.txt > sorted_pdb_textfile.txt

Thank you so much! Since I'm using mac and sort in terminal really helped!

Log in to answer this question.