clintval/sample-sheet

Order of columns in Data section

Closed this issue · 5 comments

Hi,

I am using using your fantastic library to manipulate existing sample sheets and I have a question/request:

Is it possible to retain/control the order of the columns in the Data section?

I know the order should not really matter, but we try to stick to internal conventions for readability. Besides, the reordering makes it a bit more difficult to compare the original and modified versions of the sample sheets we process.

Perhaps using an OrderedDict instead of just a dict could be a possiblity...?
https://docs.python.org/3/library/collections.html#collections.OrderedDict

Thanks!
Florian

Dictionaries are ordered in Py3.6+ implicitly and became a language feature in 3.7.

Could your provide a sample sheet in which the keys are read from a file and then written in a different order?

Oh nevermind! I understand your request. The code to change would effectively be here:

samples_header = RECOMMENDED_KEYS + sorted(other_keys)
writer.writerow(pad_iterable(samples_header, csv_width))

I've been meaning to fix #51 this week so I'll build this into my time. Thanks for the request! I think it's a great addition and will definitely help with running a checksum or diff on a sample sheet.

Great, thanks!
I do have a second request. I will open a new issue though.

Hi @reisingerf I spent some suiting this issue today! With the changes, I did break the API a little in order to support ordered case-insensitive key access within samples and sections.

Could you check out the project on master and let me know if it suits you?

Also I spun-up auto-documentation for this project which will help describe the API. I will also post change-logs and deprecations going forward (as I trend towards v1).

http://sample-sheet.readthedocs.io/

Eager to hear your thoughts. Thanks!

I had a quick run with out current sample sheet and it looks good to me.
I like the additional warnings (especially since I can disable them, if required).

Thanks a lot for addressing this so quickly!