{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "Write_sh_file.ipynb", "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "code", "source": [ "#Mount Google Drive\n", "from google.colab import drive\n", "drive.mount('/content/drive')" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "H1vtyy63ItD9", "outputId": "bd8375aa-eb4e-433a-fdbb-b9b4baeebb6d" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Mounted at /content/drive\n" ] } ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "uyqZcyu7Hc2_" }, "outputs": [], "source": [ "#Set range for file names\n", "START = 281\n", "STOP = 694\n", "#Set consistent part of SRR accession number\n", "srr_begin = \"SRR8737\"\n", "\n", "#Open file and begin writing\n", "sh_file = open(r\"/content/drive/MyDrive/AMR/File_Loading/fastq_to_contig.sh\", \"w\")\n", "sh_file.write(\"#!/usr/bin/bash\\n\\n\")\n", "\n", "#Create loop for printing commands\n", "for i in range(START,STOP):\n", " if (i>535 and i<595 and i!=592 and i!=540):\n", " break\n", " #Set remainder of command to be printed\n", " output_path = \"Contig_FASTQ/%s%s\" %(srr_begin,str(i))\n", " input_path_1 = \"FASTQ/%s%s/%s%s_1.fastq\"%(srr_begin,str(i),srr_begin,str(i))\n", " input_path_2 = \"FASTQ/%s%s/%s%s_2.fastq\"%(srr_begin,str(i),srr_begin,str(i))\n", " final_string = \"python3 /home/ssur/Applications/SPAdes-3.15.4-Linux/bin/spades.py -o %s -1 %s -2 %s\\n\"%(output_path, input_path_1, input_path_2)\n", " sh_file.write(final_string)\n", "sh_file.close()" ] } ] }