123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- <?php
- $feature = $variables['node']->feature;
- $num_bases = 50;
- $residues ='';
- if(strcmp($feature->type_id->name,'scaffold') !=0 and
- strcmp($feature->type_id->name,'chromosome') !=0 and
- strcmp($feature->type_id->name,'supercontig') !=0 and
- strcmp($feature->type_id->name,'pseudomolecule') !=0) {
- $feature = chado_expand_var($feature,'field','feature.residues');
- $residues = $feature->residues;
- }
- $feature = $variables['node']->feature;
- $featureloc_sequences = $feature->featureloc_sequences;
- if ($residues or count($featureloc_sequences) > 0) {
- $sequences_html = '';
- $list_items = array();
-
-
- if ($residues) {
- $list_items[] = '<a href="#residues">' . $feature->type_id->name . ' sequence</a>';
-
- $sequences_html .= '<a name="residues"></a>';
- $sequences_html .= '<div id="residues" class="tripal_feature-sequence-item">';
- $sequences_html .= '<p><b>' . $feature->type_id->name . ' sequence</b></p>';
- $sequences_html .= '<pre class="tripal_feature-sequence">';
- $sequences_html .= '>' . tripal_get_fasta_defline($feature, '', NULL, '', strlen($feature->residues)) . "<br>";
- $sequences_html .= wordwrap($feature->residues, $num_bases, "<br>", TRUE);
- $sequences_html .= '</pre>';
- $sequences_html .= '<a href="#sequences-top">back to top</a>';
- $sequences_html .= '</div>';
- }
-
-
-
-
- $all_relationships = $feature->all_relationships;
- $object_rels = $all_relationships['object'];
- $has_coding_seq = 0;
- $coding_seq = '';
- foreach ($object_rels as $rel_type => $rels){
- foreach ($rels as $subject_type => $subjects){
- foreach ($subjects as $subject){
-
- if ($rel_type == 'derives from' and $subject_type == 'polypeptide') {
- $protein = $subject->record->subject_id;
- $protein = chado_expand_var($protein, 'field', 'feature.residues');
- if ($protein->residues) {
- $list_items[] = '<a href="#residues">protein sequence</a>';
- $sequences_html .= '<a name="protein-' . $protein->feature_id . '"></a>';
- $sequences_html .= '<div id="protein-' . $protein->feature_id . '" class="tripal_feature-sequence-item">';
- $sequences_html .= '<p><b>protein sequence of ' . $protein->name . '</b></p>';
- $sequences_html .= '<pre class="tripal_feature-sequence">';
- $sequences_html .= '>' . tripal_get_fasta_defline($protein, '', NULL, '', strlen($protein->residues)) . "<br>";
- $sequences_html .= wordwrap($protein->residues, $num_bases, "<br>", TRUE);
- $sequences_html .= '</pre>';
- $sequences_html .= '<a href="#sequences-top">back to top</a>';
- $sequences_html .= '</div>';
- }
- }
-
-
- if ($rel_type == 'part of' and $subject_type == 'CDS') {
- $cds = $subject->record->subject_id;
- $cds = chado_expand_var($cds, 'field', 'feature.residues');
- if ($cds->residues) {
- $has_coding_seq = 1;
- $coding_seq .= $cds->residues;
- }
- }
-
-
- }
- }
- }
-
-
- if ($has_coding_seq) {
- $list_items[] = '<a href="#coding_sequence">coding sequence </a>';
- $sequences_html .= '<a name="coding_sequence"></a>';
- $sequences_html .= '<div id="coding_sequence" class="tripal_feature-sequence-item">';
- $sequences_html .= '<p><b>coding sequence</b></p>';
- $sequences_html .= '<pre class="tripal_feature-sequence">';
- $sequences_html .= wordwrap($coding_seq, $num_bases, "<br>", TRUE);
- $sequences_html .= '</pre>';
- $sequences_html .= '<a href="#sequences-top">back to top</a>';
- $sequences_html .= '</div>';
- }
-
- if(count($featureloc_sequences) > 0){
- foreach($featureloc_sequences as $src => $attrs){
-
-
-
-
-
-
-
- $list_items[] = '<a href="#' . $attrs['id'] . '">'. $feature->type_id->name . ' from alignment at ' . $attrs['location'] . "</a>";
- $sequences_html .= '<a name="' . $attrs['id'] . '"></a>';
- $sequences_html .= '<div id="' . $attrs['id'] . '" class="tripal_feature-sequence-item">';
- $sequences_html .= '<p><b>'. $feature->type_id->name . ' from alignment at ' . $attrs['location'] .'</b></p>';
- $sequences_html .= $attrs['formatted_seq'];
- $sequences_html .= '<a href="#sequences-top">back to top</a>';
- $sequences_html .= '</div>';
- }
-
- $cds_sequence = tripal_get_feature_sequences(
- array(
- 'feature_id' => $feature->feature_id,
- 'parent_id' => $attrs['featureloc']->srcfeature_id->feature_id,
- 'name' => $feature->name,
- 'featureloc_id' => $attrs['featureloc']->featureloc_id,
- ),
- array(
- 'width' => $num_bases,
- 'derive_from_parent' => 1,
- 'aggregate' => 1,
- 'sub_feature_types' => array('CDS'),
- 'is_html' => 1
- )
- );
- if (count($cds_sequence) > 0) {
-
-
-
-
- if ($cds_sequence[0]['residues']) {
- $list_items[] = '<a href="#coding_' . $attrs['id'] . '">coding sequence from alignment at ' . $attrs['location'] . "</a>";
- $sequences_html .= '<a name="ccoding_' . $attrs['id'] . '"></a>';
- $sequences_html .= '<div id="coding_' . $attrs['id'] . '" class="tripal_feature-sequence-item">';
- $sequences_html .= '<p><b>Coding sequence (CDS) from alignment at ' . $attrs['location'] . '</b></p>';
- $sequences_html .= '<pre class="tripal_feature-sequence">';
- $sequences_html .= '>' . tripal_get_fasta_defline($feature, '', $attrs['featureloc'], 'CDS', $cds_sequence[0]['length']) . "<br>";
- $sequences_html .= $cds_sequence[0]['residues'];
- $sequences_html .= '</pre>';
- $sequences_html .= '<a href="#sequences-top">back to top</a>';
- $sequences_html .= '</div>';
- }
- }
- }
- ?>
- <div class="tripal_feature-data-block-desc tripal-data-block-desc">The following sequences are available for this feature:</div>
- <?php
- // first add a list at the top of the page that can be formatted as the
- // user desires. We use the theme_item_list function of Drupal to create
- // the list rather than hard-code the HTML here. Instructions for how
- // to create the list can be found here:
- // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_item_list/7
- print '<a name="sequences-top"></a>';
- print theme_item_list(array(
- 'items' => $list_items,
- 'title' => '',
- 'type' => 'ul',
- 'attributes' => array(),
- ));
- $message = 'Administrators, sequences will appear on this page if:
- <br><br><b>For any feature type:</b>
- <ul>
- <li>This feature has residues stored in the "residues" field of the feature table of Chado.</li>
- <li>This feature is aligned to another feature (e.g. scaffold, or chromosome). In this case, the
- sequence underlying the alignment will be shown.</li>
- </ul>
- <br><b>For gene models:</b>
- <ul>
- <li>This feature has a "polypeptide" (protein) feature associated via the "feature_relationship" table of Chado with a
- relationship of type "derives from" and the protein feature has residues. Typically, a protein
- is associated with an mRNA feature and protein sequences will appear on the mRNA page.</li>
- <li>This feature has one or more CDS features associated via the "feature_relationship" table of Chado with a
- relationship of type "part of". If the CDS features have residues then those will be concatenated
- and presented as a sequence. Typically, CDSs are associated with an mRNA feature and CDS sequences
- will appear on the mRNA page.</li>
- <li>This feature is aligned to another feature (e.g. scaffold, or chromosome) and this feature has
- one or more CDS features associated. The CDS sequenes underlying the alignment will be
- shown.</li>
- </ul>
- </p>';
- print tripal_set_message($message, TRIPAL_INFO, array('return_html' => 1));
- // now print the sequences
- print $sequences_html;
- }
|