/test/functional/test_get_data.py

https://bitbucket.org/cistrome/cistrome-harvard/ · Python · 639 lines · 367 code · 118 blank · 154 comment · 0 complexity · dc27a6774ab8ce31c04b2474425282fb MD5 · raw file

  1. from base.twilltestcase import TwillTestCase
  2. from base.test_db_util import (
  3. get_user,
  4. get_latest_history_for_user,
  5. get_latest_hda,
  6. )
  7. admin_user = None
  8. class UploadData( TwillTestCase ):
  9. def test_0000_setup_upload_tests( self ):
  10. """
  11. Configuring upload tests, setting admin_user
  12. """
  13. self.logout()
  14. self.login( email='test@bx.psu.edu' )
  15. global admin_user
  16. admin_user = get_user( email='test@bx.psu.edu' )
  17. def create_fresh_history( self, user ):
  18. """
  19. Deletes latest history for the given user, checks for an empty history,
  20. and returns that new, empty history
  21. """
  22. # in order to remove a lot of boiler plate - and not have cascading errors
  23. history = get_latest_history_for_user( user )
  24. self.delete_history( id=self.security.encode_id( history.id ) )
  25. self.is_history_empty()
  26. return get_latest_history_for_user( user )
  27. def test_0005_upload_file( self ):
  28. """
  29. Test uploading 1.bed, NOT setting the file format
  30. """
  31. history = self.create_fresh_history( admin_user )
  32. self.upload_file( '1.bed' )
  33. hda = get_latest_hda()
  34. assert hda is not None, "Problem retrieving hda from database"
  35. self.verify_dataset_correctness( '1.bed', hid=str( hda.hid ) )
  36. self.check_history_for_string( "<th>1.Chrom</th><th>2.Start</th><th>3.End</th>" )
  37. self.delete_history( id=self.security.encode_id( history.id ) )
  38. def test_0006_upload_file( self ):
  39. """
  40. Test uploading 1.bed.spaces, with space to tab selected, NOT setting the file format
  41. """
  42. history = self.create_fresh_history( admin_user )
  43. self.upload_file( '1.bed.spaces', space_to_tab=True )
  44. hda = get_latest_hda()
  45. assert hda is not None, "Problem retrieving hda from database"
  46. self.verify_dataset_correctness( '1.bed', hid=str( hda.hid ) )
  47. self.check_history_for_string( "<th>1.Chrom</th><th>2.Start</th><th>3.End</th>" )
  48. self.delete_history( id=self.security.encode_id( history.id ) )
  49. def test_0010_upload_file( self ):
  50. """
  51. Test uploading 4.bed.gz, manually setting the file format
  52. """
  53. history = self.create_fresh_history( admin_user )
  54. self.upload_file( '4.bed.gz', dbkey='hg17', ftype='bed' )
  55. hda = get_latest_hda()
  56. assert hda is not None, "Problem retrieving hda from database"
  57. self.verify_dataset_correctness( '4.bed', hid=str( hda.hid ) )
  58. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
  59. "peek", "<th>1.Chrom</th><th>2.Start</th><th>3.End</th>", use_string_contains=True )
  60. self.delete_history( id=self.security.encode_id( history.id ) )
  61. def test_0012_upload_file( self ):
  62. """
  63. Test uploading 4.bed.bz2, manually setting the file format
  64. """
  65. history = self.create_fresh_history( admin_user )
  66. self.upload_file( '4.bed.bz2', dbkey='hg17', ftype='bed' )
  67. hda = get_latest_hda()
  68. assert hda is not None, "Problem retrieving hda from database"
  69. self.verify_dataset_correctness( '4.bed', hid=str( hda.hid ) )
  70. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
  71. "peek", "<th>1.Chrom</th><th>2.Start</th><th>3.End</th>", use_string_contains=True )
  72. self.delete_history( id=self.security.encode_id( history.id ) )
  73. def test_0015_upload_file( self ):
  74. """
  75. Test uploading 1.scf, manually setting the file format
  76. """
  77. history = self.create_fresh_history( admin_user )
  78. self.upload_file( '1.scf', ftype='scf' )
  79. hda = get_latest_hda()
  80. assert hda is not None, "Problem retrieving hda from database"
  81. self.verify_dataset_correctness( '1.scf', hid=str( hda.hid ) )
  82. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
  83. "peek", "Binary scf sequence file", use_string_contains=True )
  84. self.delete_history( id=self.security.encode_id( history.id ) )
  85. def test_0020_upload_file( self ):
  86. """
  87. Test uploading 1.scf, NOT setting the file format
  88. """
  89. history = self.create_fresh_history( admin_user )
  90. self.upload_file( '1.scf' )
  91. hda = get_latest_hda()
  92. assert hda is not None, "Problem retrieving hda from database"
  93. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
  94. "misc_info", "File Format' to 'Scf' when uploading scf files", use_string_contains=True )
  95. self.delete_history( id=self.security.encode_id( history.id ) )
  96. def test_0025_upload_file( self ):
  97. """
  98. Test uploading 4.bed.zip, manually setting the file format
  99. """
  100. history = self.create_fresh_history( admin_user )
  101. self.upload_file( '4.bed.zip', ftype='bed' )
  102. hda = get_latest_hda()
  103. assert hda is not None, "Problem retrieving hda from database"
  104. self.verify_dataset_correctness( '4.bed', hid=str( hda.hid ) )
  105. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
  106. "peek", "<th>1.Chrom</th><th>2.Start</th><th>3.End</th>", use_string_contains=True )
  107. self.delete_history( id=self.security.encode_id( history.id ) )
  108. def test_0030_upload_file( self ):
  109. """
  110. Test uploading 4.bed.zip, NOT setting the file format
  111. """
  112. history = self.create_fresh_history( admin_user )
  113. self.upload_file( '4.bed.zip' )
  114. hda = get_latest_hda()
  115. assert hda is not None, "Problem retrieving hda from database"
  116. self.verify_dataset_correctness( '4.bed', hid=str( hda.hid ) )
  117. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
  118. "peek", "<th>1.Chrom</th><th>2.Start</th><th>3.End</th>", use_string_contains=True )
  119. self.delete_history( id=self.security.encode_id( history.id ) )
  120. def test_0035_upload_file( self ):
  121. """
  122. Test uploading 1.sam NOT setting the file format
  123. """
  124. history = self.create_fresh_history( admin_user )
  125. self.upload_file( '1.sam' )
  126. hda = get_latest_hda()
  127. assert hda is not None, "Problem retrieving hda from database"
  128. self.verify_dataset_correctness( '1.sam', hid=str( hda.hid ) )
  129. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
  130. "peek", "<th>1.QNAME</th><th>2.FLAG</th><th>3.RNAME</th><th>4.POS</th>", use_string_contains=True )
  131. self.delete_history( id=self.security.encode_id( history.id ) )
  132. def test_0040_upload_file( self ):
  133. """
  134. Test uploading 1.sff, NOT setting the file format
  135. """
  136. history = self.create_fresh_history( admin_user )
  137. self.upload_file( '1.sff' )
  138. hda = get_latest_hda()
  139. assert hda is not None, "Problem retrieving hda from database"
  140. self.verify_dataset_correctness( '1.sff', hid=str( hda.hid ) )
  141. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
  142. "misc_info", "sff", use_string_contains=True )
  143. self.delete_history( id=self.security.encode_id( history.id ) )
  144. def test_0045_upload_file( self ):
  145. """
  146. Test uploading 454Score.pdf, NOT setting the file format
  147. """
  148. history = self.create_fresh_history( admin_user )
  149. self.upload_file( '454Score.pdf' )
  150. hda = get_latest_hda()
  151. assert hda is not None, "Problem retrieving hda from database"
  152. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
  153. "name", "454Score.pdf" )
  154. self.delete_history( id=self.security.encode_id( history.id ) )
  155. def test_0050_upload_file( self ):
  156. """
  157. Test uploading 454Score.png, NOT setting the file format
  158. """
  159. history = self.create_fresh_history( admin_user )
  160. self.upload_file( '454Score.png' )
  161. hda = get_latest_hda()
  162. assert hda is not None, "Problem retrieving hda from database"
  163. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
  164. "name", "454Score.png" )
  165. self.delete_history( id=self.security.encode_id( history.id ) )
  166. def test_0055_upload_file( self ):
  167. """
  168. Test uploading lped composite datatype file, manually setting the file format
  169. """
  170. # Logged in as admin_user
  171. history = self.create_fresh_history( admin_user )
  172. # lped data types include a ped_file and a map_file ( which is binary )
  173. self.upload_file( None, ftype='lped', metadata=[ { 'name':'base_name', 'value':'rgenetics' } ], composite_data=[ { 'name':'ped_file', 'value':'tinywga.ped' }, { 'name':'map_file', 'value':'tinywga.map'} ] )
  174. # Get the latest hid for testing
  175. hda = get_latest_hda()
  176. assert hda is not None, "Problem retrieving hda from database"
  177. # We'll test against the resulting ped file and map file for correctness
  178. self.verify_composite_datatype_file_content( 'tinywga.ped', str( hda.id ), base_name='rgenetics.ped' )
  179. self.verify_composite_datatype_file_content( 'tinywga.map', str( hda.id ), base_name='rgenetics.map' )
  180. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
  181. "metadata_base_name", "rgenetics", use_string_contains=True )
  182. self.delete_history( id=self.security.encode_id( history.id ) )
  183. def test_0056_upload_file( self ):
  184. """
  185. Test uploading lped composite datatype file, manually setting the file format, and using space to tab on one file (tinywga.ped)
  186. """
  187. # Logged in as admin_user
  188. history = self.create_fresh_history( admin_user )
  189. # lped data types include a ped_file and a map_file ( which is binary )
  190. self.upload_file( None, ftype='lped', metadata=[ { 'name':'base_name', 'value':'rgenetics' } ], composite_data=[ { 'name':'ped_file', 'value':'tinywga.ped', 'space_to_tab':True }, { 'name':'map_file', 'value':'tinywga.map'} ] )
  191. # Get the latest hid for testing
  192. hda = get_latest_hda()
  193. assert hda is not None, "Problem retrieving hda from database"
  194. # We'll test against the resulting ped file and map file for correctness
  195. self.verify_composite_datatype_file_content( 'tinywga.ped.space_to_tab', str( hda.id ), base_name='rgenetics.ped' )
  196. self.verify_composite_datatype_file_content( 'tinywga.map', str( hda.id ), base_name='rgenetics.map' )
  197. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
  198. "metadata_base_name", "rgenetics", use_string_contains=True )
  199. self.delete_history( id=self.security.encode_id( history.id ) )
  200. def test_0060_upload_file( self ):
  201. """
  202. Test uploading pbed composite datatype file, manually setting the file format
  203. """
  204. # Logged in as admin_user
  205. history = self.create_fresh_history( admin_user )
  206. # pbed data types include a bim_file, a bed_file and a fam_file
  207. self.upload_file( None, ftype='pbed',
  208. metadata=[ { 'name':'base_name', 'value':'rgenetics' } ],
  209. composite_data=[
  210. { 'name':'bim_file', 'value':'tinywga.bim' },
  211. { 'name':'bed_file', 'value':'tinywga.bed' },
  212. { 'name':'fam_file', 'value':'tinywga.fam' } ])
  213. # Get the latest hid for testing
  214. hda = get_latest_hda()
  215. assert hda is not None, "Problem retrieving hda from database"
  216. # We'll test against the resulting ped file and map file for correctness
  217. self.verify_composite_datatype_file_content( 'tinywga.bim', str( hda.id ), base_name='rgenetics.bim' )
  218. self.verify_composite_datatype_file_content( 'tinywga.bed', str( hda.id ), base_name='rgenetics.bed' )
  219. self.verify_composite_datatype_file_content( 'tinywga.fam', str( hda.id ), base_name='rgenetics.fam' )
  220. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
  221. "metadata_base_name", "rgenetics", use_string_contains=True )
  222. self.delete_history( id=self.security.encode_id( history.id ) )
  223. def test_0065_upload_file( self ):
  224. """
  225. Test uploading asian_chars_1.txt, NOT setting the file format
  226. """
  227. # Logged in as admin_user
  228. history = self.create_fresh_history( admin_user )
  229. self.upload_file( 'asian_chars_1.txt' )
  230. hda = get_latest_hda()
  231. assert hda is not None, "Problem retrieving hda from database"
  232. self.verify_dataset_correctness( 'asian_chars_1.txt', hid=str( hda.hid ) )
  233. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
  234. "misc_info", "uploaded multi-byte char file", use_string_contains=True )
  235. self.delete_history( id=self.security.encode_id( history.id ) )
  236. def test_0070_upload_file( self ):
  237. """
  238. Test uploading 2gen.fastq, NOT setting the file format
  239. """
  240. # Logged in as admin_user
  241. history = self.create_fresh_history( admin_user )
  242. self.upload_file( '2gen.fastq' )
  243. hda = get_latest_hda()
  244. assert hda is not None, "Problem retrieving hda from database"
  245. self.verify_dataset_correctness( '2gen.fastq', hid=str( hda.hid ) )
  246. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "fastq" )
  247. self.delete_history( id=self.security.encode_id( history.id ) )
  248. def test_0075_upload_file( self ):
  249. """
  250. Test uploading 1.wig, NOT setting the file format
  251. """
  252. # Logged in as admin_user
  253. history = self.create_fresh_history( admin_user )
  254. self.upload_file( '1.wig' )
  255. hda = get_latest_hda()
  256. assert hda is not None, "Problem retrieving hda from database"
  257. self.verify_dataset_correctness( '1.wig', hid=str( hda.hid ) )
  258. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "wig" )
  259. self.check_metadata_for_string( 'value="1.wig" value="\?"' )
  260. self.check_metadata_for_string( 'Change data type selected value="wig" selected="yes"' )
  261. self.delete_history( id=self.security.encode_id( history.id ) )
  262. def test_0080_upload_file( self ):
  263. """
  264. Test uploading 1.tabular, NOT setting the file format
  265. """
  266. # Logged in as admin_user
  267. history = self.create_fresh_history( admin_user )
  268. self.upload_file( '1.tabular' )
  269. hda = get_latest_hda()
  270. assert hda is not None, "Problem retrieving hda from database"
  271. self.verify_dataset_correctness( '1.tabular', hid=str( hda.hid ) )
  272. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "tabular" )
  273. self.check_metadata_for_string( 'value="1.tabular" value="\?"' )
  274. self.check_metadata_for_string( 'Change data type selected value="tabular" selected="yes"' )
  275. self.delete_history( id=self.security.encode_id( history.id ) )
  276. def test_0085_upload_file( self ):
  277. """
  278. Test uploading qualscores.qualsolid, NOT setting the file format
  279. """
  280. # Logged in as admin_user
  281. history = self.create_fresh_history( admin_user )
  282. self.upload_file( 'qualscores.qualsolid' )
  283. hda = get_latest_hda()
  284. assert hda is not None, "Problem retrieving hda from database"
  285. self.verify_dataset_correctness( 'qualscores.qualsolid', hid=str( hda.hid ) )
  286. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "qualsolid" )
  287. self.check_metadata_for_string( 'Change data type value="qualsolid" selected="yes">qualsolid' )
  288. self.delete_history( id=self.security.encode_id( history.id ) )
  289. def test_0090_upload_file( self ):
  290. """
  291. Test uploading qualscores.qual454, NOT setting the file format
  292. """
  293. # Logged in as admin_user
  294. history = self.create_fresh_history( admin_user )
  295. self.upload_file( 'qualscores.qual454' )
  296. hda = get_latest_hda()
  297. assert hda is not None, "Problem retrieving hda from database"
  298. self.verify_dataset_correctness( 'qualscores.qual454', hid=str( hda.hid ) )
  299. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "qual454" )
  300. self.check_metadata_for_string( 'Change data type value="qual454" selected="yes">qual454' )
  301. self.delete_history( id=self.security.encode_id( history.id ) )
  302. def test_0095_upload_file( self ):
  303. """
  304. Test uploading 3.maf, NOT setting the file format
  305. """
  306. # Logged in as admin_user
  307. history = self.create_fresh_history( admin_user )
  308. self.upload_file( '3.maf' )
  309. hda = get_latest_hda()
  310. assert hda is not None, "Problem retrieving hda from database"
  311. self.verify_dataset_correctness( '3.maf', hid=str( hda.hid ) )
  312. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "maf" )
  313. self.check_metadata_for_string( 'value="3.maf" value="\?"' )
  314. self.check_metadata_for_string( 'Convert to new format <option value="interval">Convert MAF to Genomic Intervals <option value="fasta">Convert MAF to Fasta' )
  315. self.check_metadata_for_string( 'Change data type selected value="maf" selected="yes"' )
  316. self.delete_history( id=self.security.encode_id( history.id ) )
  317. def test_0100_upload_file( self ):
  318. """
  319. Test uploading 1.lav, NOT setting the file format
  320. """
  321. # Logged in as admin_user
  322. history = self.create_fresh_history( admin_user )
  323. self.upload_file( '1.lav' )
  324. hda = get_latest_hda()
  325. assert hda is not None, "Problem retrieving hda from database"
  326. self.verify_dataset_correctness( '1.lav', hid=str( hda.hid ) )
  327. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "lav" )
  328. self.check_metadata_for_string( 'value="1.lav" value="\?"' )
  329. self.check_metadata_for_string( 'Change data type selected value="lav" selected="yes"' )
  330. self.delete_history( id=self.security.encode_id( history.id ) )
  331. def test_0105_upload_file( self ):
  332. """
  333. Test uploading 1.interval, NOT setting the file format
  334. """
  335. # Logged in as admin_user
  336. history = self.create_fresh_history( admin_user )
  337. self.upload_file( '1.interval' )
  338. hda = get_latest_hda()
  339. assert hda is not None, "Problem retrieving hda from database"
  340. self.verify_dataset_correctness( '1.interval', hid=str( hda.hid ) )
  341. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "interval" )
  342. self.check_metadata_for_string( 'value="1.interval" value="\?"' )
  343. self.check_metadata_for_string( 'Chrom column: <option value="1" selected> Start column: <option value="2" selected>' )
  344. self.check_metadata_for_string( 'End column: <option value="3" selected> Strand column <option value="6" selected>' )
  345. self.check_metadata_for_string( 'Convert to new format <option value="bed">Convert Genomic Intervals To BED' )
  346. self.check_metadata_for_string( 'Change data type selected value="interval" selected="yes"' )
  347. self.delete_history( id=self.security.encode_id( history.id ) )
  348. def test_0110_upload_file( self ):
  349. """
  350. Test uploading 5.gff3, NOT setting the file format
  351. """
  352. # Logged in as admin_user
  353. history = self.create_fresh_history( admin_user )
  354. self.upload_file( '5.gff3' )
  355. hda = get_latest_hda()
  356. assert hda is not None, "Problem retrieving hda from database"
  357. self.verify_dataset_correctness( '5.gff3', hid=str( hda.hid ) )
  358. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "gff3" )
  359. self.check_metadata_for_string( 'value="5.gff3" value="\?"' )
  360. self.check_metadata_for_string( 'Convert to new format <option value="bed">Convert GFF to BED' )
  361. self.check_metadata_for_string( 'Change data type selected value="gff3" selected="yes"' )
  362. self.delete_history( id=self.security.encode_id( history.id ) )
  363. def test_0115_upload_file( self ):
  364. """
  365. Test uploading html_file.txt, NOT setting the file format
  366. """
  367. # Logged in as admin_user
  368. history = self.create_fresh_history( admin_user )
  369. self.upload_file( 'html_file.txt' )
  370. hda = get_latest_hda()
  371. assert hda is not None, "Problem retrieving hda from database"
  372. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ),
  373. "misc_info", "The uploaded file contains inappropriate HTML content", use_string_contains=True )
  374. self.delete_history( id=self.security.encode_id( history.id ) )
  375. def test_0120_upload_file( self ):
  376. """
  377. Test uploading 5.gff, NOT setting the file format
  378. Test sniffer for gff.
  379. """
  380. history = self.create_fresh_history( admin_user )
  381. self.upload_file( '5.gff' )
  382. hda = get_latest_hda()
  383. assert hda is not None, "Problem retrieving hda from database"
  384. self.verify_dataset_correctness( '5.gff', hid=str( hda.hid ) )
  385. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "gff" )
  386. self.check_metadata_for_string( 'value="5.gff" value="\?"' )
  387. self.check_metadata_for_string( 'Convert to new format <option value="bed">Convert GFF to BED' )
  388. self.check_metadata_for_string( 'Change data type selected value="gff" selected="yes"' )
  389. self.delete_history( id=self.security.encode_id( history.id ) )
  390. def test_0125_upload_file( self ):
  391. """
  392. Test uploading 1.fasta, NOT setting the file format
  393. """
  394. # Logged in as admin_user
  395. history = self.create_fresh_history( admin_user )
  396. self.upload_file( '1.fasta' )
  397. hda = get_latest_hda()
  398. assert hda is not None, "Problem retrieving hda from database"
  399. self.verify_dataset_correctness( '1.fasta', hid=str( hda.hid ) )
  400. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "fasta" )
  401. self.check_metadata_for_string( 'value="1.fasta" value="\?" Change data type selected value="fasta" selected="yes"' )
  402. self.delete_history( id=self.security.encode_id( history.id ) )
  403. def test_0130_upload_file( self ):
  404. """
  405. Test uploading 1.customtrack, NOT setting the file format
  406. """
  407. # Logged in as admin_user
  408. history = self.create_fresh_history( admin_user )
  409. self.upload_file( '1.customtrack' )
  410. hda = get_latest_hda()
  411. assert hda is not None, "Problem retrieving hda from database"
  412. self.verify_dataset_correctness( '1.customtrack', hid=str( hda.hid ) )
  413. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "customtrack" )
  414. self.check_metadata_for_string( 'value="1.customtrack" value="\?" Change data type selected value="customtrack" selected="yes"' )
  415. self.delete_history( id=self.security.encode_id( history.id ) )
  416. def test_0135_upload_file( self ):
  417. """
  418. Test uploading shrimp_cs_test1.csfasta, NOT setting the file format
  419. """
  420. # Logged in as admin_user
  421. history = self.create_fresh_history( admin_user )
  422. self.upload_file( 'shrimp_cs_test1.csfasta' )
  423. hda = get_latest_hda()
  424. assert hda is not None, "Problem retrieving hda from database"
  425. self.verify_dataset_correctness( 'shrimp_cs_test1.csfasta', hid=str( hda.hid ) )
  426. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "csfasta" )
  427. self.check_metadata_for_string( 'value="shrimp_cs_test1.csfasta" value="\?" Change data type value="csfasta" selected="yes"' )
  428. self.delete_history( id=self.security.encode_id( history.id ) )
  429. def test_0145_upload_file( self ):
  430. """
  431. Test uploading 1.axt, NOT setting the file format
  432. """
  433. # Logged in as admin_user
  434. history = self.create_fresh_history( admin_user )
  435. self.upload_file( '1.axt' )
  436. hda = get_latest_hda()
  437. assert hda is not None, "Problem retrieving hda from database"
  438. self.verify_dataset_correctness( '1.axt', hid=str( hda.hid ) )
  439. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "axt" )
  440. self.check_metadata_for_string( 'value="1.axt" value="\?" Change data type selected value="axt" selected="yes"' )
  441. self.delete_history( id=self.security.encode_id( history.id ) )
  442. def test_0150_upload_file( self ):
  443. """
  444. Test uploading 1.bam, which is a sorted Bam file creaed by the Galaxy sam_to_bam tool, NOT setting the file format
  445. """
  446. history = self.create_fresh_history( admin_user )
  447. self.upload_file( '1.bam' )
  448. hda = get_latest_hda()
  449. assert hda is not None, "Problem retrieving hda from database"
  450. self.verify_dataset_correctness( '1.bam', hid=str( hda.hid ), attributes={ 'ftype' : 'bam' } )
  451. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "bam" )
  452. # Make sure the Bam index was created
  453. assert hda.metadata.bam_index is not None, "Bam index was not correctly created for 1.bam"
  454. self.delete_history( id=self.security.encode_id( history.id ) )
  455. def test_0155_upload_file( self ):
  456. """
  457. Test uploading 3unsorted.bam, which is an unsorted Bam file, NOT setting the file format
  458. """
  459. history = self.create_fresh_history( admin_user )
  460. self.upload_file( '3unsorted.bam' )
  461. hda = get_latest_hda()
  462. assert hda is not None, "Problem retrieving hda from database"
  463. # Since 3unsorted.bam is not sorted, we cannot verify dataset correctness since the uploaded
  464. # dataset will be sorted. However, the check below to see if the index was created is
  465. # sufficient.
  466. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "bam" )
  467. # Make sure the Bam index was created
  468. assert hda.metadata.bam_index is not None, "Bam index was not correctly created for 3unsorted.bam"
  469. self.delete_history( id=self.security.encode_id( history.id ) )
  470. def test_0160_url_paste( self ):
  471. """
  472. Test url paste behavior
  473. """
  474. # Logged in as admin_user
  475. history = self.create_fresh_history( admin_user )
  476. self.upload_url_paste( 'hello world' )
  477. self.check_history_for_exact_string( 'Pasted Entry' )
  478. self.check_history_for_exact_string( 'hello world' )
  479. self.upload_url_paste( u'hello world' )
  480. self.check_history_for_exact_string( 'Pasted Entry' )
  481. self.check_history_for_exact_string( 'hello world' )
  482. self.delete_history( id=self.security.encode_id( history.id ) )
  483. def test_0165_upload_file( self ):
  484. """
  485. Test uploading 1.pileup, NOT setting the file format
  486. """
  487. history = self.create_fresh_history( admin_user )
  488. self.upload_file( '1.pileup' )
  489. hda = get_latest_hda()
  490. assert hda is not None, "Problem retrieving hda from database"
  491. self.verify_dataset_correctness( '1.pileup', hid=str( hda.hid ) )
  492. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "pileup" )
  493. self.check_metadata_for_string( 'value="1.pileup" value="\?" Change data type selected value="pileup" selected="yes"' )
  494. self.delete_history( id=self.security.encode_id( history.id ) )
  495. def test_0170_upload_file( self ):
  496. """
  497. Test uploading 1.bigbed, NOT setting the file format
  498. """
  499. history = self.create_fresh_history( admin_user )
  500. self.upload_file( '1.bigbed' )
  501. hda = get_latest_hda()
  502. assert hda is not None, "Problem retrieving hda from database"
  503. self.verify_dataset_correctness( '1.bigbed', hid=str( hda.hid ) )
  504. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "bigbed" )
  505. self.check_metadata_for_string( 'value="1.bigbed" value="\?" Change data type selected value="bigbed" selected="yes"' )
  506. self.delete_history( id=self.security.encode_id( history.id ) )
  507. def test_0175_upload_file( self ):
  508. """
  509. Test uploading 1.bigwig, NOT setting the file format
  510. """
  511. history = self.create_fresh_history( admin_user )
  512. self.upload_file( '1.bigwig' )
  513. hda = get_latest_hda()
  514. assert hda is not None, "Problem retrieving hda from database"
  515. self.verify_dataset_correctness( '1.bigwig', hid=str( hda.hid ) )
  516. self.check_hda_json_for_key_value( self.security.encode_id( hda.id ), "data_type", "bigwig" )
  517. self.check_metadata_for_string( 'value="1.bigwig" value="\?" Change data type selected value="bigwig" selected="yes"' )
  518. self.delete_history( id=self.security.encode_id( history.id ) )
  519. def test_9999_clean_up( self ):
  520. self.logout()