1 | import galaxy.model |
---|
2 | from galaxy.model.orm import * |
---|
3 | from galaxy.model.mapping import context as sa_session |
---|
4 | from base.twilltestcase import TwillTestCase |
---|
5 | |
---|
6 | """ A sample analysis""" |
---|
7 | |
---|
8 | class AnalysisDNAseHSSFlankedGenes( TwillTestCase ): |
---|
9 | def test_get_DNAseHSS_flanked_genes( self ): |
---|
10 | self.logout() |
---|
11 | self.login( email='test@bx.psu.edu' ) |
---|
12 | admin_user = sa_session.query( galaxy.model.User ) \ |
---|
13 | .filter( galaxy.model.User.table.c.email=='test@bx.psu.edu' ) \ |
---|
14 | .one() |
---|
15 | self.new_history( name='DNAseHSS_flanked_genes' ) |
---|
16 | history1 = sa_session.query( galaxy.model.History ) \ |
---|
17 | .filter( and_( galaxy.model.History.table.c.deleted==False, |
---|
18 | galaxy.model.History.table.c.user_id==admin_user.id ) ) \ |
---|
19 | .order_by( desc( galaxy.model.History.table.c.create_time ) ) \ |
---|
20 | .first() |
---|
21 | track_params = dict( |
---|
22 | db="hg17", |
---|
23 | hgta_group="regulation", |
---|
24 | hgta_table="dukeDnaseCd4Sites", |
---|
25 | hgta_track="dukeDnaseCd4Sites", |
---|
26 | hgta_regionType="range", |
---|
27 | position="chr22", |
---|
28 | hgta_outputType="bed", |
---|
29 | sendToGalaxy="1" |
---|
30 | ) |
---|
31 | output_params = dict( |
---|
32 | fbQual="whole", |
---|
33 | ) |
---|
34 | # Test 1 |
---|
35 | self.run_ucsc_main( track_params, output_params ) |
---|
36 | self.wait() |
---|
37 | self.verify_dataset_correctness('DNAseHSS.dat') |
---|
38 | latest_hda = sa_session.query( galaxy.model.HistoryDatasetAssociation ) \ |
---|
39 | .order_by( desc( galaxy.model.HistoryDatasetAssociation.table.c.create_time ) ) \ |
---|
40 | .first() |
---|
41 | # Due to twill not being able to handle the permissions forms, we'll eliminate |
---|
42 | # DefaultHistoryPermissions prior to uploading a dataset so that the permission |
---|
43 | # form will not be displayed on ted edit attributes page. |
---|
44 | for dp in latest_hda.dataset.actions: |
---|
45 | sa_session.delete( dp ) |
---|
46 | sa_session.flush() |
---|
47 | sa_session.refresh( latest_hda.dataset ) |
---|
48 | self.edit_hda_attribute_info( str( latest_hda.id ), new_name="DNAse HS" ) |
---|
49 | self.check_metadata_for_string( "DNAse HS" ) |
---|
50 | track_params = dict( |
---|
51 | db="hg17", |
---|
52 | hgta_group="genes", |
---|
53 | hgta_table="knownGene", |
---|
54 | hgta_track="knownGene", |
---|
55 | hgta_regionType="range", |
---|
56 | position="chr22", |
---|
57 | hgta_outputType="bed", |
---|
58 | sendToGalaxy="1" |
---|
59 | ) |
---|
60 | output_params = dict( |
---|
61 | fbQual="whole", |
---|
62 | ) |
---|
63 | # Test 2 |
---|
64 | self.run_ucsc_main( track_params, output_params ) |
---|
65 | self.wait() |
---|
66 | self.verify_dataset_correctness('hg17chr22KnownGenes.dat') |
---|
67 | latest_hda = sa_session.query( galaxy.model.HistoryDatasetAssociation ) \ |
---|
68 | .order_by( desc( galaxy.model.HistoryDatasetAssociation.table.c.create_time ) ) \ |
---|
69 | .first() |
---|
70 | for dp in latest_hda.dataset.actions: |
---|
71 | sa_session.delete( dp ) |
---|
72 | sa_session.flush() |
---|
73 | sa_session.refresh( latest_hda.dataset ) |
---|
74 | self.edit_hda_attribute_info( str( latest_hda.id ), new_name="Genes" ) |
---|
75 | self.check_metadata_for_string( "Genes" ) |
---|
76 | # Test 3 |
---|
77 | self.run_tool( 'get_flanks1', input="2", region="whole", direction="Upstream", offset="0", size="500" ) |
---|
78 | self.wait() |
---|
79 | self.verify_dataset_correctness( 'knownGeneUpstream500Flanks.dat' ) |
---|
80 | latest_hda = sa_session.query( galaxy.model.HistoryDatasetAssociation ) \ |
---|
81 | .order_by( desc( galaxy.model.HistoryDatasetAssociation.table.c.create_time ) ) \ |
---|
82 | .first() |
---|
83 | for dp in latest_hda.dataset.actions: |
---|
84 | sa_session.delete( dp ) |
---|
85 | sa_session.flush() |
---|
86 | sa_session.refresh( latest_hda.dataset ) |
---|
87 | self.edit_hda_attribute_info( str( latest_hda.id ), new_name="Flanks" ) |
---|
88 | self.check_metadata_for_string( "Flanks" ) |
---|
89 | # Test 4 |
---|
90 | self.run_tool( 'gops_join_1', input1="3", input2="1", min="1", fill="none" ) |
---|
91 | self.wait() |
---|
92 | # We cannot verify this dataset, because this tool spits out data in a non-deterministic order |
---|
93 | #self.verify_dataset_correctness( 'joinFlanksDNAse.dat' ) |
---|
94 | # Test 5 |
---|
95 | self.run_tool( 'Filter1', input="4", cond="c17==1000" ) |
---|
96 | self.wait() |
---|
97 | self.verify_dataset_correctness( 'filteredJoinedFlanksDNAse.dat' ) |
---|
98 | self.delete_history( self.security.encode_id( history1.id ) ) |
---|
99 | self.logout() |
---|