changeset 0:e3b52db3d583 draft

planemo upload commit abb24d36c776520e73220d11386252d848173697-dirty
author proteore
date Sun, 26 Nov 2017 19:45:52 -0500
parents
children bfc679370c64
files get_data_nextprot.R prot_features.xml
diffstat 2 files changed, 283 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/get_data_nextprot.R	Sun Nov 26 19:45:52 2017 -0500
@@ -0,0 +1,138 @@
+# Usage : Rscript --vanilla get_data_nextprot.R --inputtype copypaste (or
+# tabfile) --input file.txt --nextprot result_nextprot.txt --column column
+# --argsP1 IsoPoint,SeqLength,MW
+# --argsP2 Chr,SubcellLocations --argsP3 Diseases --type id nextprot (uniprot)
+# --output output.txt --header TRUE
+
+# e.g : 
+# Rscript --vanilla get_data_nextprot.R --inputtype copypaste  --input P01133 P00533 P62158 Q16566 P31323 P17612 P10644
+# P22612 P31321 P13861 P22694 P25098 P16220 Q14573 Q14571 Q14643 Q05655 Q02156
+# P19174 O43865 Q01064 P54750 Q14123 P51828 Q08828 O60266 Q08462 O60503 O43306
+# Q8NFM4 O95622 P40145 P17252 P05129 --nextprot
+# result_nextprot.txt--column c1 --argsP1 IsoPoint --argsP2
+# Chr --argsP3 Diseases --typeid uniprot --output output.txt --header FALSE
+
+# Useful functions
+
+'%!in%' <- function(x,y)!('%in%'(x,y))
+
+# Parse arguments
+
+args = commandArgs(trailingOnly = TRUE)
+
+# create a list of the arguments from the command line, separated by a blank space
+hh <- paste(unlist(args),collapse=' ')
+# delete the first element of the list which is always a blank space
+listoptions <- unlist(strsplit(hh,'--'))[-1]
+# for each input, split the arguments with blank space as separator, unlist, and delete the first element which is the input name (e.g --protalas) 
+options.args <- sapply(listoptions,function(x){
+         unlist(strsplit(x, ' '))[-1]
+        })
+# same as the step above, except that only the names are kept
+options.names <- sapply(listoptions,function(x){
+  option <-  unlist(strsplit(x, ' '))[1]
+})
+names(options.args) <- unlist(options.names)
+
+
+typeinput = as.character(options.args[1])
+nextprot = read.table(as.character(options.args[3]),header=TRUE,sep="\t",quote="\"") 
+listfile = as.character(options.args[2])
+column = as.numeric(gsub("c","",options.args[4]))
+P1_args = as.character(options.args[5])
+P2_args = as.character(options.args[6])
+P3_args = as.character(options.args[7])
+typeid = as.character(options.args[8])
+filename = as.character(options.args[9])
+header = as.character(options.args[10])
+
+if (typeinput=="copypaste"){
+  sample = as.data.frame(unlist(listfile))
+  sample = sample[,column]
+}
+if (typeinput=="tabfile"){
+  
+  if (header=="TRUE"){
+    listfile = read.table(listfile,header=TRUE,sep="\t",quote="\"",fill=TRUE)
+  }else{
+    listfile = read.table(listfile,header=FALSE,sep="\t",quote="\"",fill=TRUE)
+  }
+  sample = listfile[,column]
+
+}
+# Change the sample ids if they are uniprot ids to be able to match them with
+# Nextprot data
+if (typeid=="uniprot"){
+  sample = gsub("^","NX_",sample)
+}
+
+# Select user input protein ids in nextprot
+
+if ((length(sample[sample %in% nextprot[,1]]))==0){
+
+    write.table("None of the input ids are can be found in Nextprot",file=filename,sep="\t",quote=FALSE,col.names=TRUE,row.names=FALSE)
+
+}else{ 
+
+	
+	to_keep = c()
+	
+	if (P1_args!="None"){
+	  P1_args = unlist(strsplit(P1_args,","))
+	  for (arg in P1_args){
+	    colnb = which(colnames(nextprot) %in% c(arg))
+	    to_keep = c(to_keep,colnb)    
+	  }
+	}
+	
+	if (P2_args!="None"){
+	  P2_args = unlist(strsplit(P2_args,","))
+	  for (arg in P2_args){
+	    colnb = which(colnames(nextprot) %in% c(arg))
+	    to_keep = c(to_keep,colnb)    
+	  }
+	}
+	
+	if (P3_args!="None"){
+	  P3_args = unlist(strsplit(P3_args,","))
+	  for (arg in P3_args){
+	    colnb = which(colnames(nextprot) %in% c(arg))
+	    to_keep = c(to_keep,colnb)    
+	  }
+	}
+	to_keep = c(1,to_keep)
+	lines = which(nextprot[,1] %in% sample)
+  data = nextprot[lines,]
+  
+  data = data[,to_keep]
+
+
+  # if only some of the proteins were not found in nextprot they will be added to
+	# the file with the fields "Protein not found in Nextprot"
+	if (length(which(sample %!in% nextprot[,1]))!=0){
+	  proteins_not_found = as.data.frame(sample[which(sample %!in% nextprot[,1])])
+	
+	  proteins_not_found = cbind(proteins_not_found,matrix(rep("Protein not found in Nextprot",length(proteins_not_found)),nrow=length(proteins_not_found),ncol=length(colnames(data))-1))
+
+  colnames(proteins_not_found)=colnames(data) 
+	 data = rbind(data,proteins_not_found)
+	}
+  
+  # Merge original data and data selected from nextprot
+
+  # Before that, if the initial ids were uniprot ids change them back from
+  # Nextprot to uniprot ids in data 
+  if (typeid=="uniprot"){
+    data[,1] = gsub("^NX_","",data[,1])
+  }
+  data = merge(listfile, data, by.x = column, by.y=1)
+  if (typeid=="uniprot"){
+    colnames(data)[1] = "UniprotID"	
+  }
+  if (typeid=="nextprot"){
+    colnames(data)[1] = "NextprotID"	
+  }
+  # Write result
+  write.table(data,file=filename,sep="\t",quote=FALSE,col.names=TRUE,row.names=FALSE)
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/prot_features.xml	Sun Nov 26 19:45:52 2017 -0500
@@ -0,0 +1,145 @@
+<tool id="prot_features" name="Protein Features (neXtProt)" version="0.1.0">
+<description>
+obtains different features of your protein list from neXtProt.
+</description>
+<requirements>
+</requirements>
+<stdio>
+  <exit_code range="1:" />
+</stdio>
+<command><![CDATA[
+
+  #if $inputtype.filetype == "copy_paste":  
+    Rscript --vanilla $__tool_directory__/get_data_nextprot.R --inputtype copypaste --input '$inputtype.genelist' --nextprot $__tool_directory__/result_nextprot.txt --column c1 --argsP1 '$Nextprot_params.P1' --argsP2 '$Nextprot_params.P2'--argsP3 '$Nextprot_params.P3' --type '$idtype' --output '$output' --header None 
+  #end if
+
+  #if $inputtype.filetype == "file_all": 
+  
+  Rscript --vanilla $__tool_directory__/get_data_nextprot.R --inputtype tabfile --input '$inputtype.genelist' --nextprot $__tool_directory__/result_nextprot.txt --column '$inputtype.column' --argsP1 '$Nextprot_params.P1' --argsP2 '$Nextprot_params.P2'--argsP3 '$Nextprot_params.P3' --type '$idtype' --output '$output' --header '$inputtype.header' 
+
+  #end if
+    
+
+]]></command>
+
+<inputs>
+  <conditional name="inputtype">
+    <param name="filetype" type="select" label="Select your type of input file"> 
+      <option value="file_all">Input file containing your identifiers</option>
+      <option value="copy_paste">Copy/paste your list of IDs</option> 
+    </param>
+    <when value="copy_paste">
+      <param name="genelist" type="text" label="Enter a list of identifiers"/>
+    </when>
+    <when value="file_all">
+      <param name="genelist" type="data" format="txt,tabular" label="Choose a multiple-columns file" help="This file must imperatively have 1 column filled with IDs consistent with the database that will be used. Please use the MappingIDs component if this is not the case."/>
+      <param name="column" type="text" label="Please specify the column where you would like to apply the comparison (e.g : Enter c1)" value="c1"/> 
+      <param name="header" type="select" label="Does your file have a header?" multiple="false" optional="false"> 
+ 	  <option value="TRUE" selected="true">Yes</option>
+          <option value="FALSE" selected="false">No</option>
+      </param>
+    </when>
+  </conditional>
+      <param name="idtype" type="select" label="Type of your input ids" multiple="false" optional="false"> 
+ 	  <option value="nextprot" selected="false">Nextprot IDs</option>
+          <option value="uniprot" selected="true">Uniprot IDs</option>
+      </param>
+
+      <section name="Nextprot_params" title="Choose the type of information (compulsory step)" expanded="True">
+        <param name="P1" type="select" label="Physico-Chemical Features" multiple="true" help="Choose the information you want to add to your data from Nextprot" display="checkboxes" optional="true"> 
+          <option value="MW" selected="false">Molecular Weight</option>
+ 	  <option value="SeqLength" selected="false">Sequence Length</option>
+          <option value="IsoPoint" selected="false">Isoelectric point</option>
+          <option value="TMDomains" selected="false">Number of transmembrane domains</option>
+          <option value="ProteinExistence" selected="false">Protein Existence (PE level)</option>
+        </param>
+
+        <param name="P2" type="select" label="Localization" multiple="true" help="Choose the information you want to add to your data from Nextprot" display="checkboxes" optional="true"> 
+ 	  <option value="Chr" selected="false">Chromosome</option>
+ 	  <option value="SubcellLocations" selected="false">Subcellular Location</option>
+        </param>
+
+        <param name="P3" type="select" label="Diseases information">
+          <option value="Diseases">Yes</option>
+          <option value="None">No</option>
+        </param>
+      </section>
+
+</inputs>
+
+
+<outputs>
+  <data name="output" format="tsv" label="Add information from ${database_type.database}"/>
+
+
+</outputs>
+
+
+<tests>
+  <test>
+    <conditional name="inputtype">
+      <param name="filetype " value="tabfile"/>
+      <param name="genelist" value="mitochondrion_enzymes_Nextprot.txt"/>
+      <param name="column" value="c1"/>
+      <param name="header" value="TRUE"/>
+    </conditional>
+
+    <param name="idtype" value="nextprot"/> 
+
+      <section name="Nextprot_params">
+        <param name="P1" value="MW,SeqLength,IsoPoint,TMDomains,ProteinExistence"/> 
+        <param name="P2" value="Chr,SubcellLocations"/> 
+        <param name="P3" value="Diseases"/> 
+      </section>
+
+    <output name="output" file="output_get_data.tsv"/>
+  </test>
+</tests>
+
+<help><![CDATA[
+
+This tool filters an input **tabular** file according to different databases.
+
+**Input**
+
+Input can be a file containing multiple fields but with **at least one column of Ensembl gene IDs** or a list of Ensembl gene ids. If your input file contains other kind of IDs, please refer to the MappingIDs component to create a column of Ensembl gene IDs.  
+
+**Databases**
+
+The input file will be filtered using information from different sources : 
+
+- HPA normal tissue : will filter the input according to the data contained in the Human Protein Atlas webservice. Pertinent information, such as tissular location, will be added for each gene to your input file.  
+
+- HPA cancer tissue :  will filter the input according to the data contained in the Human Protein Atlas webservice for cancer. Pertinent information, such as tumor type, will be added for each gene to your input file.  
+
+**Parameters**
+
+For HPA normal tissue :
+
+- tissue category : categories based on RNA-Seq data to estimate the transcript abundance of each protein-coding gene in tissues. For more information, please refer to http://www.proteinatlas.org/about/assays+annotation#rna .
+
+- level of detection IF : level of detection of the protein associated to the coding gene tissues based on immunofluorescency. For more information, please refer to http://www.proteinatlas.org/about/assays+annotation#if .
+
+- level of detection IH :  level of detection of the protein associated to the coding gene tissues based on immunohistochemistry. For more information, please refer to http://www.proteinatlas.org/about/assays+annotation#if .
+
+For HPA cancer tissue : 
+
+- tumors : which tumors are associated with your protein-coding genes according to the Human Protein Atlas.
+
+
+**Outputs**
+
+The output will be a tabular file. The initial columns will be kept, but lines can be deleted due to the filtering process. Additional columns will be added according to which data you chose to filter your input with.  
+
+
+**Data sources**
+
+The data for HPA normal tissue was retrieved from the Human Protein Atlas downloadable data repository (http://www.proteinatlas.org/download/proteinatlas.tab.gz).
+
+The data for HPA cancer was retrieved from the Human Protein Atlas downloadable data repository (http://www.proteinatlas.org/download/cancer.csv.zip).
+]]></help>
+
+<citations>
+</citations>
+
+</tool>