Mercurial > repos > davidvanzessen > combined_immune_repertoire_imgt
comparison imgtconvert.py @ 6:8418fab78894 draft
Uploaded
author | davidvanzessen |
---|---|
date | Tue, 10 Dec 2013 08:06:50 -0500 |
parents | d2b3bcabb478 |
children |
comparison
equal
deleted
inserted
replaced
5:3ce07f5889ad | 6:8418fab78894 |
---|---|
16 | 16 |
17 old_summary_columns = [u'Sequence ID', u'JUNCTION frame', u'V-GENE and allele', u'D-GENE and allele', u'J-GENE and allele', u'CDR1-IMGT length', u'CDR2-IMGT length', u'CDR3-IMGT length', u'Orientation'] | 17 old_summary_columns = [u'Sequence ID', u'JUNCTION frame', u'V-GENE and allele', u'D-GENE and allele', u'J-GENE and allele', u'CDR1-IMGT length', u'CDR2-IMGT length', u'CDR3-IMGT length', u'Orientation'] |
18 old_sequence_columns = [u'CDR1-IMGT', u'CDR2-IMGT', u'CDR3-IMGT'] | 18 old_sequence_columns = [u'CDR1-IMGT', u'CDR2-IMGT', u'CDR3-IMGT'] |
19 old_junction_columns = [u'JUNCTION'] | 19 old_junction_columns = [u'JUNCTION'] |
20 | 20 |
21 added_summary_columns = [u'V-REGION identity %', u'V-REGION identity nt', u'D-REGION reading frame', u'AA JUNCTION', u'Functionality comment', u'Sequence'] | 21 added_summary_columns = [u'Functionality', u'V-REGION identity %', u'V-REGION identity nt', u'D-REGION reading frame', u'AA JUNCTION', u'Functionality comment', u'Sequence'] |
22 added_sequence_columns = [u'FR1-IMGT', u'FR2-IMGT', u'FR3-IMGT', u'CDR3-IMGT', u'JUNCTION', u'J-REGION', u'FR4-IMGT'] | 22 added_sequence_columns = [u'FR1-IMGT', u'FR2-IMGT', u'FR3-IMGT', u'CDR3-IMGT', u'JUNCTION', u'J-REGION', u'FR4-IMGT'] |
23 added_junction_columns = [u"P3'V-nt nb", u'N1-REGION-nt nb', u"P5'D-nt nb", u"P3'D-nt nb", u'N2-REGION-nt nb', u"P5'J-nt nb", u"3'V-REGION trimmed-nt nb", u"5'D-REGION trimmed-nt nb", u"3'D-REGION trimmed-nt nb", u"5'J-REGION trimmed-nt nb"] | 23 added_junction_columns = [u"P3'V-nt nb", u'N1-REGION-nt nb', u"P5'D-nt nb", u"P3'D-nt nb", u'N2-REGION-nt nb', u"P5'J-nt nb", u"3'V-REGION trimmed-nt nb", u"5'D-REGION trimmed-nt nb", u"3'D-REGION trimmed-nt nb", u"5'J-REGION trimmed-nt nb"] |
24 | 24 |
25 inputFolder = args.input | 25 inputFolder = args.input |
26 | 26 |
105 for col in added_junction_columns: | 105 for col in added_junction_columns: |
106 tmp[col] = fJunction[col] | 106 tmp[col] = fJunction[col] |
107 | 107 |
108 outFrame = outFrame.append(tmp) | 108 outFrame = outFrame.append(tmp) |
109 | 109 |
110 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', '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'] | 110 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'] |
111 | 111 |
112 vPattern = re.compile(r"IGHV[1-9]-[0-9ab]+-?[1-9]?") | 112 vPattern = re.compile(r"IGHV[1-9]-[0-9ab]+-?[1-9]?") |
113 dPattern = re.compile(r"IGHD[1-9]-[0-9ab]+") | 113 dPattern = re.compile(r"IGHD[1-9]-[0-9ab]+") |
114 jPattern = re.compile(r"IGHJ[1-9]") | 114 jPattern = re.compile(r"IGHJ[1-9]") |
115 | 115 |
131 tmp = outFrame["VDJ Frame"] | 131 tmp = outFrame["VDJ Frame"] |
132 tmp = tmp.replace("in-frame", "In-frame") | 132 tmp = tmp.replace("in-frame", "In-frame") |
133 tmp = tmp.replace("null", "Out-of-frame") | 133 tmp = tmp.replace("null", "Out-of-frame") |
134 tmp = tmp.replace("out-of-frame", "Out-of-frame") | 134 tmp = tmp.replace("out-of-frame", "Out-of-frame") |
135 outFrame["VDJ Frame"] = tmp | 135 outFrame["VDJ Frame"] = tmp |
136 outFrame["CDR3 Length"] = outFrame["CDR3 Seq DNA"].map(str).map(len) | 136 outFrame["CDR3 Length DNA"] = outFrame["CDR3 Seq DNA"].map(str).map(len) |
137 safeLength = lambda x: len(x) if type(x) == str else 0 | 137 safeLength = lambda x: len(x) if type(x) == str else 0 |
138 outFrame = outFrame[(outFrame["CDR3 Seq DNA"].map(safeLength) > 0) & (outFrame["Top V Gene"] != "NA") & (outFrame["Top D Gene"] != "NA") & (outFrame["Top J Gene"] != "NA")] #filter out weird rows? | 138 outFrame = outFrame[(outFrame["CDR3 Seq DNA"].map(safeLength) > 0) & (outFrame["Top V Gene"] != "NA") & (outFrame["Top D Gene"] != "NA") & (outFrame["Top J Gene"] != "NA")] #filter out weird rows? |
139 outFrame.to_csv(outFile, sep="\t", index=False) | 139 outFrame.to_csv(outFile, sep="\t", index=False, index_label="index") |