Merge branch 'master' into topic/dt_feature_search
[sgn.git] / t / legacy / integration / feature_gene_group.t
blob63cb8399c0a7b7aabcfef7d12048398faea7a2e0
1 use strict;
2 use warnings;
4 use Test::More;
6 use lib 't/lib';
7 use SGN::Test::WWW::Mechanize skip_cgi => 1;
8 use SGN::Test::Data qw/create_test/;
10 # set up test gene groups
11 my $group = create_test('Sequence::Feature');
12 my @orgs = map create_test('Organism::Organism'), 0..2;
13 my $schema = $group->result_source->schema;
14 for ( [ $orgs[0], 4 ], [ $orgs[1], 2 ], [ $orgs[2], 5 ] ) {
15     my ( $org, $count ) = @$_;
16     for( 1..$count ) {
17         my $gene = create_test('Sequence::Feature',{
18             type     => $schema->get_cvterm_or_die('sequence:gene'),
19             organism => $org,
20         });
21         add_relationship( $gene, 'sequence:member_of', $group );
23         my $mrna = create_test('Sequence::Feature', {
24             type => $schema->get_cvterm_or_die('sequence:mRNA'),
25             organism => $org,
26             residues => 'CATCATCATCAT',
27         });
28         add_relationship( $mrna, 'relationship:part_of', $gene );
30         my $poly = create_test('Sequence::Feature', {
31             type => $schema->get_cvterm_or_die('sequence:polypeptide'),
32             organism => $org,
33             residues => 'MMMMMMMMMMMMMM',
34         });
35         add_relationship( $poly, 'relationship:derives_from', $mrna );
36     }
39 my $mech = SGN::Test::WWW::Mechanize->new;
40 $mech->get_ok('/feature/'.$group->name.'/details');
41 $mech->get_ok('/feature/'.$group->name.'/gene_group_protein_fasta');
42 $mech->content_contains('>feature_');
43 $mech->content_contains('MMMMMMMMMM');
44 #diag $mech->content;
46 done_testing;
48 exit;
50 #####################################################
52 sub add_relationship {
53     my ( $subject, $relationship, $object ) = @_;
55     $subject->add_to_feature_relationship_subjects(
56         { type   => $schema->get_cvterm_or_die( $relationship ),
57           object => $object,
58         },
59     );