Skip to content

Commit

Permalink
Merge pull request #969 from kencho51/FixBug-dataset-image-not-showing
Browse files Browse the repository at this point in the history
Fix bug dataset image not showing
  • Loading branch information
rija authored Mar 9, 2022
2 parents f51bff8 + e8453ab commit 0d0079d
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 16 deletions.
3 changes: 2 additions & 1 deletion data/dev/dataset.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ The assembled scaffolds of high quality sequences total 1.23 Gb, with the contig
144,163,147,100094,Data and software to accompany the paper: Applying compressed sensing to genome-wide association studies.,"The aim of a genome-wide association study (GWAS) is to isolate DNA markers for variants affecting phenotypes of interest. Linear regression is employed for this purpose, and in recent years a signal-processing paradigm known as compressed sensing (CS) has coalesced around a particular class of regression techniques. CS is not a method in its own right, but rather a body of theory regarding signal recovery when the number of predictor variables (i.e., genotyped markers) exceeds the sample size. The paper shows the applicability of compressed sensing (CS) theory to genome-wide association studies (GWAS), where the purpose is to find trait-associated tagging markers (genetic variants). Analysis scripts are contained in the compressed CS file. Mock data and scripts are found in the compressed GD file. The example scripts found in the CS repository require the GD files to be unpacked in a separate folder. Please look at accompanying readme pdfs for both repositories and annotations in the example scripts before using.",171860992,ftp://parrot.genomics.cn/gigadb/pub/10.5524/100001_101000/100094,Published,,,2014-06-06,,1,AWLGPriZKd41XEaS,,,,
200,336,212,100142,"Supporting scripts and data for ""Investigation into the annotation of protocol sequencing steps in the Sequence Read Archive"".","The workflow for the production of high-throughput sequencing data from nucleic acid samples is complex. There are a series of protocol steps to be followed in the preparation of samples for next-generation sequencing. The quantification of bias in a number of protocol steps, namely DNA fractionation, blunting, phosphorylation, adapter ligation and library enrichment, remains to be determined.
We examined the experimental metadata of the public repository Sequence Read Archive (SRA) in order to ascertain the level of annotation of important sequencing steps in submissions to the database. ",384263168,ftp://parrot.genomics.cn/gigadb/pub/10.5524/100001_101000/100142/,Published,100142newversion.xls,a98f1c13a46501707fb3fba270deb6e3,2015-05-11,,3,eG8EFsRibZQzrtNw,,,,
668,38,669,200070,supporting data for nothing in particular,"well now, how to describe nothing in particular?",32,https://ftp.cngb.org/pub/gigadb/pub,Private,,,,,1,ImP3Bbu7ytRSfYFh,,38,none,
668,38,669,200070,supporting data for nothing in particular,"well now, how to describe nothing in particular?",32,https://ftp.cngb.org/pub/gigadb/pub,Private,,,,,1,ImP3Bbu7ytRSfYFh,,38,none,
700,14,700,300070,test dataset,"test generic image will be display for no image dataset",32,https://ftp.cngb.org/pub/gigadb/pub,Published,,,,,1,,,38,none,
1 change: 1 addition & 0 deletions data/dev/image.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ id,location,tag,url,license,photographer,source
147,"",CS icon1,"",public domain,Shashaank Vattikuti ,Gigascience
212,100142.jpg,Overlap between different protocol search terms,http://gigadb.org/images/data/cropped/100142.jpg,CC0,Alnasir and Shanahan 2015,Alnasir and Shanahan 2015
669,"",no image icon,var/www/hosts/localhost/htdocs/images/uploads/image_upload/Images_1885.png,Public domain,GigaDB,GigaDB
700,no_image.png,no image icon,"",Public domain,GigaDB,GigaDB
2 changes: 1 addition & 1 deletion ops/configuration/yii-conf/migration.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class {{ class_name }} extends CDbMigration
{{#each safeup_data}}
$this->insert('{{ ../table_name }}', array(
{{#each this}}
{{#if this}}
{{#if (isdefined @key this) }}
'{{@key}}' => '{{this}}',
{{/if}}
{{/each}}
Expand Down
7 changes: 7 additions & 0 deletions ops/scripts/csv_yii_migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ for(let a = 0; a < files.length; a ++) {
safeup_data: parsed.data,
safedown_data: filtered_ids
};
// Register sub expression to decide whether a value is defined based on its key
handlebars.registerHelper('isdefined', function (key, value) {
if (key == 'url') {
return value !== undefined;
}
return !handlebars.Utils.isEmpty(value);
});
// Read handlebars template as string
let template = fs.readFileSync(HANDLEBARS_TEMPLATE_FILE, "utf8");
const templateScript = handlebars.compile(template);
Expand Down
3 changes: 3 additions & 0 deletions ops/scripts/setup_devdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ docker-compose run --rm test psql -h database -U gigadb < protected/runtime/drop
# Perform data migrations
$DOCKER_COMPOSE run --rm application ./protected/yiic migrate --connectionID=db --migrationPath=application.migrations.data.$dbSet --interactive=0

# update the url for project images and dataset images
$DOCKER_COMPOSE run --rm application ./protected/yiic migrate --connectionID=db --migrationPath=application.migrations.fix_import --interactive=0

# Restore constraints, indexes and triggers
docker-compose run --rm test psql -h database -U gigadb < protected/runtime/addConstraintsQuery.sql
docker-compose run --rm test psql -h database -U gigadb < protected/runtime/addIndexQuery.sql
Expand Down
4 changes: 4 additions & 0 deletions ops/scripts/setup_testdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ $DOCKER_COMPOSE run --rm application ./protected/yiic migrate to 300000_000000
$DOCKER_COMPOSE run --rm application ./protected/yiic migrate mark 000000_000000 --connectionID=testdb --interactive=0
$DOCKER_COMPOSE run --rm application ./protected/yiic migrate --connectionID=testdb --migrationPath=application.migrations.schema --interactive=0
$DOCKER_COMPOSE run --rm application ./protected/yiic migrate --connectionID=testdb --migrationPath=application.migrations.data.$dbSet --interactive=0

# update the url for project images and dataset images
$DOCKER_COMPOSE run --rm application ./protected/yiic migrate --connectionID=testdb --migrationPath=application.migrations.fix_import --interactive=0

# export a binary dump
$DOCKER_COMPOSE run --rm test bash -c "pg_dump --no-owner -U gigadb -h database -p 5432 -F custom -d $dbSet -f /var/www/sql/$dbSet.pgdmp"
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public function safeUp()
Yii::app()->db->createCommand("update project set image_location = replace(image_location,'http://hpc-bioinformatics.cineca.it/fusion/imgs','');")->execute();
Yii::app()->db->createCommand("update project set image_location = replace(image_location,'https://bioinfotraining.bio.cam.ac.uk/images','');")->execute();
Yii::app()->db->createCommand("update project set image_location = replace(image_location,'http://gigadb.org/images/data/cropped','');")->execute();
Yii::app()->db->createCommand("ALTER TABLE project ALTER COLUMN image_location TYPE character varying(128);")->execute();
Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/images/projects/', lower(replace(replace(replace(name, ' ','_'),'_-_','_'),',','')), image_location) where image_location != '' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%' and name not like 'LiGeA%' and name != 'https://www.carmen.org.uk';")->execute();
Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/images/projects/', replace(name, 'LiGeA: a comprehensive database of human gene fusion events', 'ligea'), image_location) where name like 'LiGeA%' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%';")->execute();
Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/images/projects/', replace(name, 'https://www.carmen.org.uk', 'carmen'), image_location) where name = 'https://www.carmen.org.uk' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%';")->execute();
Yii::app()->db->createCommand("ALTER TABLE project ALTER COLUMN image_location TYPE character varying(255);")->execute();
Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/live/images/projects/', lower(replace(replace(replace(name, ' ','_'),'_-_','_'),',','')), image_location) where image_location != '' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%' and name not like 'LiGeA%' and name != 'https://www.carmen.org.uk';")->execute();
Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/live/images/projects/', replace(name, 'LiGeA: a comprehensive database of human gene fusion events', 'ligea'), image_location) where name like 'LiGeA%' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%';")->execute();
Yii::app()->db->createCommand("update project set image_location = concat('https://assets.gigadb-cdn.net/live/images/projects/', replace(name, 'https://www.carmen.org.uk', 'carmen'), image_location) where name = 'https://www.carmen.org.uk' and image_location not like 'https://assets.gigadb-cdn.net/images/projects/%';")->execute();
}

public function safeDown()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

class m220218_062834_update_url_image_tab extends CDbMigration
{
public function safeUp()
{
Yii::app()->db->createCommand("update image set url = replace(url, 'http://gigadb.org/','https://assets.gigadb-cdn.net/live/images/datasets/') where url like 'http://gigadb.org/%';")->execute();
Yii::app()->db->createCommand("update image set url = 'https://assets.gigadb-cdn.net/live/images/datasets/no_image.png' where url='' and location like 'no_image%';")->execute();
}

public function safeDown()
{
}
}
7 changes: 0 additions & 7 deletions protected/models/Dataset.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,6 @@ public function getDatasetTypes(){
public function getImageUrl($default='') {
if ($this->image) {
$url = $this->image->url;
if ($url) {
if (!strstr($url , 'http://')) {
$url = '//' . $url;
}
} else {
$url = $this->image->image('image_upload');
}
return $url;
}
return $default;
Expand Down
17 changes: 14 additions & 3 deletions tests/acceptance/DatasetView.feature
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,21 @@ Feature: a user visit the dataset page
Then I should see "well now, how to describe nothing in particular?"
And I should not see "The DOI 200070 cannot be displayed."

@ok
Scenario: Dataset with image associated will show dataset image
Given I have not signed in
When I am on "dataset/100006"
Then I should see an image located in "https://assets.gigadb-cdn.net/live/images/datasets/images/data/cropped/100006_Pygoscelis_adeliae.jpg"

@ok
Scenario: Dataset with no image associated will show generic image
Given I have not signed in
When I am on "dataset/300070"
Then I should see an image located in "https://assets.gigadb-cdn.net/live/images/datasets/no_image.png"

@ok @issue-895
Scenario: Project image with links
Given I have not signed in
When I am on "/dataset/100006"
Then I should see an image "https://assets.gigadb-cdn.net/images/projects/genome_10k/G10Klogo.jpg" is linked to "http://www.genome10k.org/"
And I should see an image "https://assets.gigadb-cdn.net/images/projects/the_avian_phylogenomic_project/phylogenomiclogo.png" is linked to "http://avian.genomics.cn/en/index.html"

Then I should see an image "https://assets.gigadb-cdn.net/live/images/projects/genome_10k/G10Klogo.jpg" is linked to "http://www.genome10k.org/"
And I should see an image "https://assets.gigadb-cdn.net/live/images/projects/the_avian_phylogenomic_project/phylogenomiclogo.png" is linked to "http://avian.genomics.cn/en/index.html"

0 comments on commit 0d0079d

Please sign in to comment.