Skip to content

Instantly share code, notes, and snippets.

@MikeTrizna
Last active January 7, 2019 20:32
Show Gist options
  • Select an option

  • Save MikeTrizna/d141ba415e5d632346069a25a0fbe1cb to your computer and use it in GitHub Desktop.

Select an option

Save MikeTrizna/d141ba415e5d632346069a25a0fbe1cb to your computer and use it in GitHub Desktop.
Fixing tracefile names
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "import os",
"execution_count": 1,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "correct_order = []\ncols = ['A','B','C','D','E','F','G','H']\nfor col in cols:\n for row in range(1,13):\n well = col + str(row).zfill(2)\n correct_order.append(well)\nprint(correct_order)",
"execution_count": 32,
"outputs": [
{
"output_type": "stream",
"text": "['A01', 'A02', 'A03', 'A04', 'A05', 'A06', 'A07', 'A08', 'A09', 'A10', 'A11', 'A12', 'B01', 'B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B09', 'B10', 'B11', 'B12', 'C01', 'C02', 'C03', 'C04', 'C05', 'C06', 'C07', 'C08', 'C09', 'C10', 'C11', 'C12', 'D01', 'D02', 'D03', 'D04', 'D05', 'D06', 'D07', 'D08', 'D09', 'D10', 'D11', 'D12', 'E01', 'E02', 'E03', 'E04', 'E05', 'E06', 'E07', 'E08', 'E09', 'E10', 'E11', 'E12', 'F01', 'F02', 'F03', 'F04', 'F05', 'F06', 'F07', 'F08', 'F09', 'F10', 'F11', 'F12', 'G01', 'G02', 'G03', 'G04', 'G05', 'G06', 'G07', 'G08', 'G09', 'G10', 'G11', 'G12', 'H01', 'H02', 'H03', 'H04', 'H05', 'H06', 'H07', 'H08', 'H09', 'H10', 'H11', 'H12']\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "convert = dict(zip(correct_order, reversed(correct_order)))\nprint(convert)",
"execution_count": 36,
"outputs": [
{
"output_type": "stream",
"text": "{'A01': 'H12', 'A02': 'H11', 'A03': 'H10', 'A04': 'H09', 'A05': 'H08', 'A06': 'H07', 'A07': 'H06', 'A08': 'H05', 'A09': 'H04', 'A10': 'H03', 'A11': 'H02', 'A12': 'H01', 'B01': 'G12', 'B02': 'G11', 'B03': 'G10', 'B04': 'G09', 'B05': 'G08', 'B06': 'G07', 'B07': 'G06', 'B08': 'G05', 'B09': 'G04', 'B10': 'G03', 'B11': 'G02', 'B12': 'G01', 'C01': 'F12', 'C02': 'F11', 'C03': 'F10', 'C04': 'F09', 'C05': 'F08', 'C06': 'F07', 'C07': 'F06', 'C08': 'F05', 'C09': 'F04', 'C10': 'F03', 'C11': 'F02', 'C12': 'F01', 'D01': 'E12', 'D02': 'E11', 'D03': 'E10', 'D04': 'E09', 'D05': 'E08', 'D06': 'E07', 'D07': 'E06', 'D08': 'E05', 'D09': 'E04', 'D10': 'E03', 'D11': 'E02', 'D12': 'E01', 'E01': 'D12', 'E02': 'D11', 'E03': 'D10', 'E04': 'D09', 'E05': 'D08', 'E06': 'D07', 'E07': 'D06', 'E08': 'D05', 'E09': 'D04', 'E10': 'D03', 'E11': 'D02', 'E12': 'D01', 'F01': 'C12', 'F02': 'C11', 'F03': 'C10', 'F04': 'C09', 'F05': 'C08', 'F06': 'C07', 'F07': 'C06', 'F08': 'C05', 'F09': 'C04', 'F10': 'C03', 'F11': 'C02', 'F12': 'C01', 'G01': 'B12', 'G02': 'B11', 'G03': 'B10', 'G04': 'B09', 'G05': 'B08', 'G06': 'B07', 'G07': 'B06', 'G08': 'B05', 'G09': 'B04', 'G10': 'B03', 'G11': 'B02', 'G12': 'B01', 'H01': 'A12', 'H02': 'A11', 'H03': 'A10', 'H04': 'A09', 'H05': 'A08', 'H06': 'A07', 'H07': 'A06', 'H08': 'A05', 'H09': 'A04', 'H10': 'A03', 'H11': 'A02', 'H12': 'A01'}\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "folder_list = ['12674_Mulcahy_PRBVIP4_COIF_180d',\n '12675_Mulcahy_PRBVIP4_COIR_180d']\nfor folder in folder_list:\n for filename in os.listdir(folder):\n if filename.endswith('.ab1'):\n filepath = os.path.join(folder, filename)\n current_well = filepath.replace('.ab1','').split('_')[-1]\n fixed_file = filepath.replace(current_well, convert[current_well])\n os.rename(filepath, fixed_file)",
"execution_count": 31,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.6.2",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"gist": {
"id": "",
"data": {
"description": "Dropbox (Smithsonian)/dan/Untitled.ipynb",
"public": true
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment