Mercurial > repos > abims-sbr > mutcount
comparison scripts/S02b_study_seq_composition_nuc.py @ 5:0ba551449008 draft
planemo upload for repository htpps://github.com/abims-sbr/adaptearch commit 273a9af69b672b2580cd5dec4c0e67a4a96fb0fe
| author | abims-sbr |
|---|---|
| date | Tue, 27 Feb 2018 08:48:34 -0500 |
| parents | 5766f80370e7 |
| children | f1e24200e5ae |
comparison
equal
deleted
inserted
replaced
| 4:5766f80370e7 | 5:0ba551449008 |
|---|---|
| 120 | 120 |
| 121 ## 3 ## PathOUT | 121 ## 3 ## PathOUT |
| 122 ## 3.1 ## NUC composition | 122 ## 3.1 ## NUC composition |
| 123 fileOUT_NUC=open("./OUT/nuc_compositions.csv","w") | 123 fileOUT_NUC=open("./OUT/nuc_compositions.csv","w") |
| 124 fileOUT_NUC.write("LOCUS,") | 124 fileOUT_NUC.write("LOCUS,") |
| 125 for taxa in LT: | 125 for taxa in LT[0:-1]: |
| 126 fileOUT_NUC.write("%s_prop_A,%s_prop_T,%s_prop_C,%s_prop_G," %(taxa,taxa,taxa,taxa)) | 126 fileOUT_NUC.write("%s_prop_A,%s_prop_T,%s_prop_C,%s_prop_G," %(taxa,taxa,taxa,taxa)) |
| 127 fileOUT_NUC.write("%s_prop_A,%s_prop_T,%s_prop_C,%s_prop_G" %(LT[-1],LT[-1],LT[-1],LT[-1])) | |
| 127 fileOUT_NUC.write("\n") | 128 fileOUT_NUC.write("\n") |
| 128 | 129 |
| 129 ## 3.2 ## NUC percent_GC | 130 ## 3.2 ## NUC percent_GC |
| 130 fileOUT_percent_GC=open("./OUT/percent_GC.csv","w") | 131 fileOUT_percent_GC=open("./OUT/percent_GC.csv","w") |
| 131 fileOUT_percent_GC.write("LOCUS,") | 132 fileOUT_percent_GC.write("LOCUS,") |
| 132 for taxa in LT: | 133 for taxa in LT[0:-1]: |
| 133 fileOUT_percent_GC.write("%s_percent_GC," %(taxa)) | 134 fileOUT_percent_GC.write("%s_percent_GC," %(taxa)) |
| 135 fileOUT_percent_GC.write("%s_percentGC" %(LT[-1])) | |
| 134 fileOUT_percent_GC.write("\n") | 136 fileOUT_percent_GC.write("\n") |
| 135 | 137 |
| 136 ## 3.3 ## NUC percent_purine | 138 ## 3.3 ## NUC percent_purine |
| 137 fileOUT_percent_purine=open("./OUT/percent_purine.csv","w") | 139 fileOUT_percent_purine=open("./OUT/percent_purine.csv","w") |
| 138 fileOUT_percent_purine.write("LOCUS,") | 140 fileOUT_percent_purine.write("LOCUS,") |
| 139 for taxa in LT: | 141 for taxa in LT[0:-1]: |
| 140 fileOUT_percent_purine.write("%s_percent_purine," %(taxa)) | 142 fileOUT_percent_purine.write("%s_percent_purine," %(taxa)) |
| 143 fileOUT_percent_purine.write("%s_percent_purine" %(LT[-1])) | |
| 141 fileOUT_percent_purine.write("\n") | 144 fileOUT_percent_purine.write("\n") |
| 142 | 145 |
| 143 ## 3.4 ## Purine Load | 146 ## 3.4 ## Purine Load |
| 144 fileOUT_Purine_Load=open("./OUT/Purine_Load_Indice.csv", "w") | 147 fileOUT_Purine_Load=open("./OUT/Purine_Load_Indice.csv", "w") |
| 145 fileOUT_Purine_Load.write("LOCUS,") | 148 fileOUT_Purine_Load.write("LOCUS,") |
| 146 for taxa in LT: | 149 for taxa in LT[0:-1]: |
| 147 fileOUT_Purine_Load.write("%s_TOTAL,%s_DIFF_GC,%s_DIFF_AT,%s_PLI_GC1000,%s_PLI_AT1000," %(taxa,taxa,taxa,taxa,taxa)) | 150 fileOUT_Purine_Load.write("%s_TOTAL,%s_DIFF_GC,%s_DIFF_AT,%s_PLI_GC1000,%s_PLI_AT1000," %(taxa,taxa,taxa,taxa,taxa)) |
| 151 fileOUT_Purine_Load.write("%s_TOTAL,%s_DIFF_GC,%s_DIFF_AT,%s_PLI_GC1000,%s_PLI_AT1000" %(LT[-1],LT[-1],LT[-1],LT[-1],LT[-1])) | |
| 148 fileOUT_Purine_Load.write("\n") | 152 fileOUT_Purine_Load.write("\n") |
| 149 | 153 |
| 150 ##################### | 154 ##################### |
| 151 ## 4 ## Process Loci | 155 ## 4 ## Process Loci |
| 152 ##################### | 156 ##################### |
| 158 fileOUT_NUC.write("%s," %locus) | 162 fileOUT_NUC.write("%s," %locus) |
| 159 fileOUT_percent_GC.write("%s," %locus) | 163 fileOUT_percent_GC.write("%s," %locus) |
| 160 fileOUT_percent_purine.write("%s," %locus) | 164 fileOUT_percent_purine.write("%s," %locus) |
| 161 fileOUT_Purine_Load.write("%s," %locus) | 165 fileOUT_Purine_Load.write("%s," %locus) |
| 162 | 166 |
| 163 for taxa in LT: | 167 for taxa in LT[0:-1]: |
| 164 if taxa in bash.keys(): | 168 if taxa in bash.keys(): |
| 165 seq = bash[taxa] | 169 seq = bash[taxa] |
| 166 percent_GC, percent_purine,prop_A, prop_T, prop_C, prop_G = base_composition(seq) ### DEF2 ### | 170 percent_GC, percent_purine,prop_A, prop_T, prop_C, prop_G = base_composition(seq) ### DEF2 ### |
| 167 TOTAL, DIFF_GC, DIFF_AT,PLI_GC,PLI_AT,PLI_GC_1000,PLI_AT_1000 = purine_loading(seq) ### DEF3 ### | 171 TOTAL, DIFF_GC, DIFF_AT,PLI_GC,PLI_AT,PLI_GC_1000,PLI_AT_1000 = purine_loading(seq) ### DEF3 ### |
| 168 fileOUT_NUC.write("%.5f,%.5f,%.5f,%.5f," %(prop_A,prop_T,prop_C,prop_G)) | 172 fileOUT_NUC.write("%.5f,%.5f,%.5f,%.5f," %(prop_A,prop_T,prop_C,prop_G)) |
| 173 fileOUT_NUC.write("%s,%s,%s,%s," %("NA","NA","NA","NA")) | 177 fileOUT_NUC.write("%s,%s,%s,%s," %("NA","NA","NA","NA")) |
| 174 fileOUT_percent_GC.write("%s," %"NA") | 178 fileOUT_percent_GC.write("%s," %"NA") |
| 175 fileOUT_percent_purine.write("%s," %"NA") | 179 fileOUT_percent_purine.write("%s," %"NA") |
| 176 fileOUT_Purine_Load.write("%s,%s,%s,%s,%s," %("NA","NA","NA","NA","NA")) | 180 fileOUT_Purine_Load.write("%s,%s,%s,%s,%s," %("NA","NA","NA","NA","NA")) |
| 177 | 181 |
| 182 if LT[-1] in bash.keys(): | |
| 183 seq = bash[LT[-1]] | |
| 184 percent_GC, percent_purine,prop_A, prop_T, prop_C, prop_G = base_composition(seq) ### DEF2 ### | |
| 185 TOTAL, DIFF_GC, DIFF_AT,PLI_GC,PLI_AT,PLI_GC_1000,PLI_AT_1000 = purine_loading(seq) ### DEF3 ### | |
| 186 fileOUT_NUC.write("%.5f,%.5f,%.5f,%.5f" %(prop_A,prop_T,prop_C,prop_G)) | |
| 187 fileOUT_percent_GC.write("%.5f" %percent_GC) | |
| 188 fileOUT_percent_purine.write("%.5f" %percent_purine) | |
| 189 fileOUT_Purine_Load.write("%d,%d,%d,%.5f,%.5f" %(TOTAL, DIFF_GC, DIFF_AT,PLI_GC_1000, PLI_AT_1000)) | |
| 190 else: | |
| 191 fileOUT_NUC.write("%s,%s,%s,%s" %("NA","NA","NA","NA")) | |
| 192 fileOUT_percent_GC.write("%s" %"NA") | |
| 193 fileOUT_percent_purine.write("%s" %"NA") | |
| 194 fileOUT_Purine_Load.write("%s,%s,%s,%s,%s" %("NA","NA","NA","NA","NA")) | |
| 195 | |
| 196 | |
| 178 fileOUT_NUC.write("\n") | 197 fileOUT_NUC.write("\n") |
| 179 fileOUT_percent_GC.write("\n") | 198 fileOUT_percent_GC.write("\n") |
| 180 fileOUT_percent_purine.write("\n") | 199 fileOUT_percent_purine.write("\n") |
| 181 fileOUT_Purine_Load.write("\n") | 200 fileOUT_Purine_Load.write("\n") |
| 182 fileOUT_NUC.close() | 201 fileOUT_NUC.close() |
