changeset 4:021d39f6bb0e draft

Uploaded
author davidvanzessen
date Fri, 06 Jun 2014 04:34:44 -0400
parents 191d0df65d28
children 387fce4a1dd4
files imgtconvert.py imgtconvert.xml
diffstat 2 files changed, 51 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/imgtconvert.py	Tue Mar 11 09:24:29 2014 -0400
+++ b/imgtconvert.py	Fri Jun 06 04:34:44 2014 -0400
@@ -32,9 +32,8 @@
 if len(dirContents) == 1:
     inputFolder = os.path.join(inputFolder, dirContents[0])
     if os.path.isdir(inputFolder):
-        print "is dir"
         dirContents = os.listdir(inputFolder)
-files = sorted([os.path.join(inputFolder, f) for f in dirContents])
+files = sorted([os.path.join(inputFolder, f) for f in dirContents if os.path.isfile(os.path.join(inputFolder, f))])
 
 if len(files) % 3 is not 0:
     stop_err("Files in zip not a multiple of 3, it should contain the all the 1_, 5_ and 6_ files for a sample")
@@ -78,6 +77,8 @@
 
 outFrame = tmp
 
+
+
 for triple in triplets[1:]:
     fSummary = pd.read_csv(triple[0], sep="\t")
     fSequence = pd.read_csv(triple[1], sep="\t")
@@ -110,20 +111,56 @@
 
     outFrame = outFrame.append(tmp)
 
+
 outFrame.columns = [u'ID', u'VDJ Frame', u'Top V Gene', u'Top D Gene', u'Top J Gene', u'CDR1 Seq', u'CDR1 Length', u'CDR2 Seq', u'CDR2 Length', u'CDR3 Seq', u'CDR3 Length', u'CDR3 Seq DNA', u'CDR3 Length DNA', u'Strand', u'CDR3 Found How', u'Functionality', 'V-REGION identity %', 'V-REGION identity nt', 'D-REGION reading frame', 'AA JUNCTION', 'Functionality comment', 'Sequence', 'FR1-IMGT', 'FR2-IMGT', 'FR3-IMGT', 'CDR3-IMGT', 'JUNCTION', 'J-REGION', 'FR4-IMGT', 'P3V-nt nb', 'N1-REGION-nt nb', 'P5D-nt nb', 'P3D-nt nb', 'N2-REGION-nt nb', 'P5J-nt nb', '3V-REGION trimmed-nt nb', '5D-REGION trimmed-nt nb', '3D-REGION trimmed-nt nb', '5J-REGION trimmed-nt nb']
 
-#vPattern = re.compile(r"|TRBV[0-9]{1,2}-?[0-9]?") #mouse
-#vPattern = re.compile(r"IGHV[1-9]-[0-9ab]+-?[1-9]?") #human
-vPattern = re.compile(r"IGHV[1-9]-[0-9ab]+-?[1-9]?|TRBV[0-9]{1,2}-?[0-9]?") #mouse and human
+"""
+IGHV[0-9]-[0-9ab]+-?[0-9]?D?
+TRBV[0-9]{1,2}-?[0-9]?-?[123]?
+IGKV[0-3]D?-[0-9]{1,2}
+IGLV[0-9]-[0-9]{1,2}
+TRAV[0-9]{1,2}(-[1-46])?(/DV[45678])?
+TRGV[234589]
+TRDV[1-3]
+
+IGHD[0-9]-[0-9ab]+
+TRBD[12]
+TRDD[1-3]
+
+IGHJ[1-6]
+TRBJ[12]-[1-7]
+IGKJ[1-5]
+IGLJ[12367]
+TRAJ[0-9]{1,2}
+TRGJP?[12]
+TRDJ[1-4]
+"""
 
-#dPattern = re.compile(r"TRBD1|TRBD2") #mouse
-#dPattern = re.compile(r"IGHD[1-9]-[0-9ab]+") #human
-dPattern = re.compile(r"IGHD[1-9]-[0-9ab]+|TRBD1|TRBD2") #mouse and human
+vPattern = [r"(IGHV[0-9]-[0-9ab]+-?[0-9]?D?)",
+						r"(TRBV[0-9]{1,2}-?[0-9]?-?[123]?)",
+						r"(IGKV[0-3]D?-[0-9]{1,2})",
+						r"(IGLV[0-9]-[0-9]{1,2})",
+						r"(TRAV[0-9]{1,2}(-[1-46])?(/DV[45678])?)",
+						r"(TRGV[234589])",
+						r"(TRDV[1-3])"]
 
+dPattern = [r"(IGHD[0-9]-[0-9ab]+)",
+						r"(TRBD[12])",
+						r"(TRDD[1-3])"]
+						
+jPattern = [r"(IGHJ[1-6])",
+						r"(TRBJ[12]-[1-7])",
+						r"(IGKJ[1-5])",
+						r"(IGLJ[12367])",
+						r"(TRAJ[0-9]{1,2})",
+						r"(TRGJP?[12])",
+						r"(TRDJ[1-4])"]
 
-#jPattern = re.compile(r"TRBJ[12]-[1-7]") #mouse
-#jPattern = re.compile(r"IGHJ[1-6]") #human
-jPattern = re.compile(r"IGHJ[1-6]|TRBJ[12]-[1-7]") #mouse and human
+vPattern = re.compile(r"|".join(vPattern))
+
+dPattern = re.compile(r"|".join(dPattern))
+
+jPattern = re.compile(r"|".join(jPattern))
 
 
 def filterGenes(s, pattern):
@@ -135,11 +172,12 @@
     return "NA"
 
 
+
 outFrame["Top V Gene"] = outFrame["Top V Gene"].apply(lambda x: filterGenes(x, vPattern))
 outFrame["Top D Gene"] = outFrame["Top D Gene"].apply(lambda x: filterGenes(x, dPattern))
 outFrame["Top J Gene"] = outFrame["Top J Gene"].apply(lambda x: filterGenes(x, jPattern))
 
-
+print outFrame
 
 tmp = outFrame["VDJ Frame"]
 tmp = tmp.replace("in-frame", "In-frame")
--- a/imgtconvert.xml	Tue Mar 11 09:24:29 2014 -0400
+++ b/imgtconvert.xml	Fri Jun 06 04:34:44 2014 -0400
@@ -7,7 +7,7 @@
         <param name="in_file" type="data" label="Archive with files" />
 	</inputs>
 	<outputs>
-		<data format="tabular" name="out_file" />
+		<data format="tabular" name="out_file" label="IMGT Loader on ${in_file.name}"/>
 	</outputs>
 	<help>
 		Converting all 1_Summary, 5_AA-sequence and 6_Junction files belonging to a sample from an archive (supported: 7z, rar, tar, tar.bz2, tar.gz and zip) into a single file to be used in the Immune repertoire toolchain (Step 3)