Skip to content

Commit

Permalink
addExamples
Browse files Browse the repository at this point in the history
  • Loading branch information
urmi-21 committed Jan 16, 2020
1 parent 25c7c61 commit 4f99fc8
Showing 1 changed file with 111 additions and 5 deletions.
116 changes: 111 additions & 5 deletions examples/Maize_lncRNA_prediction/Maize_lncRNAs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,122 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[93mLogs will be saved to 2020-01-16-16_27_35_pyrpipe.log\u001b[0m\n"
]
}
],
"source": [
"from pyrpipe import sra,mapping,assembly,qc,tools\n",
"#First get the srr accessions of the runs. For this one can use the python package pysradb or R package sradb\n",
"runsSmol=[]\n",
"maize_data=\"\"\n",
"working_dir=\"\""
"#runs=['SRR3098746','SRR3098745','SRR3098744'] #from the study SRP068369\n",
"runs=['SRR3098746'] #from the study SRP068369\n",
"#set up directories\n",
"maize_data=\"/home/usingh/work/urmi/hoap/test/maize/maize_data\"\n",
"workingDir=\"/home/usingh/work/urmi/hoap/test/maize\"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Download data, pre-process"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sraObjects=[]\n",
"for x in runs:\n",
" thisSraOb=sra.SRA(x,workingDir)\n",
" if thisSraOb.download_sra():\n",
" sraObjects.append(thisSraOb)\n",
" else:\n",
" print(\"Download failed:\"+x)\n",
" \n",
"#perform fastq dump and qc\n",
"\n",
"#create a Trimgalore object\n",
"tgOpts={\"--cores\": \"10\"}\n",
"tg=qc.Trimgalore(**tgOpts)\n",
"\n",
"for x in sraObjects:\n",
" #to fastq\n",
" x.run_fasterqdump(delete_sra=True,**{\"-e\":\"20\",\"-f\":\"\",\"-t\":workingDir}) #use 20 threads\n",
" #perform qc using trim galore\n",
" x.perform_qc(tg)\n",
" \n",
"\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Map using STAR"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[91m\u001b[1mCan not find STAR\u001b[0m\n"
]
},
{
"ename": "Exception",
"evalue": "ERROR: STAR not found.",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mException\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-2-96d918c7c981>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m }\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0mstar\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmapping\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mStar\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstar_index\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mstarParams\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m#provided index is invalid\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;31m#create star index\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/work/urmi/hoap/pyrpipe/pyrpipe/mapping.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, star_index, **kwargs)\u001b[0m\n\u001b[1;32m 312\u001b[0m \u001b[0;31m#check if star exists\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 313\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mpe\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcheck_dependencies\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdep_list\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 314\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"ERROR: \"\u001b[0m\u001b[0;34m+\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mprogramName\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;34m\" not found.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 315\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 316\u001b[0m self.valid_args=['--help','--parametersFiles','--sysShell','--runMode','--runThreadN','--runDirPerm','--runRNGseed','--quantMode','--quantTranscriptomeBAMcompression','--quantTranscriptomeBan','--twopassMode','--twopass1readsN',\n",
"\u001b[0;31mException\u001b[0m: ERROR: STAR not found."
]
}
],
"source": [
"starParams={\"--outFilterType\":\"BySJout\",\n",
" \"--runThreadN\":\"8\",\n",
" \"--outSAMtype\": \"BAM SortedByCoordinate\"\n",
" }\n",
"\n",
"star=mapping.Star(star_index=\"\",**starParams) #provided index is invalid\n",
"\n",
"#create star index\n",
"indexOut=maize_data+\"/starindex\"\n",
"inFasta=maize_data+\"Zea_mays.B73_RefGen_v4.dna.toplevel.1_10.fa\"\n",
"star.build_index(index_path=indexOut,inFasta)\n",
"\n",
"#after building index run star\n",
"star_out=[]\n",
"for x in sraObjects:\n",
" star_out.append(star.perform_alignment(x))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 4f99fc8

Please sign in to comment.