Skip to content

Commit

Permalink
fixed jbrowse assembly view without gene selection
Browse files Browse the repository at this point in the history
  • Loading branch information
vikasguptaebi committed Nov 15, 2024
1 parent 67bb7af commit d1d2577
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 50 deletions.
20 changes: 20 additions & 0 deletions dataportal-app/src/components/interfaces/Gene.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export interface GeneMeta {
id: number;
seq_id: string;
gene_name: string;
description: string;
strain_id: number;
strain: string;
assembly: string;
locus_tag: string;
cog: string | null;
kegg: string | null;
pfam: string | null;
interpro: string | null;
dbxref: string | null;
ec_number: string | null;
product: string | null;
start_position: number | null;
end_position: number | null;
annotations: Record<string, any> | null;
}
18 changes: 16 additions & 2 deletions dataportal-app/src/components/interfaces/Genome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export interface Contig {
length: number;
}

export interface Genome {
export interface GenomeMeta {
species: string;
id: number;
common_name: string;
Expand All @@ -18,10 +18,24 @@ export interface Genome {
}

export interface GenomeResponse {
results: Genome[];
results: GenomeMeta[];
page_number: number;
num_pages: number;
has_previous: boolean;
has_next: boolean;
total_results: number;
}


export interface Genome11Meta {
species: number;
id: number;
common_name: string;
isolate_name: string;
assembly_name: string;
assembly_accession: string;
fasta_file: string;
gff_file: string;
fasta_url: string;
gff_url: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ const GeneSearchForm: React.FC<GeneSearchFormProps> = ({
// Fetch search results based on the query, selected species, page, sort field, and sort order
const fetchSearchResults = useCallback(
async (page = 1, sortField: string, sortOrder: string) => {
console.log('111111111111')
const params = new URLSearchParams({
'query': query.trim() || '',
'page': String(page),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {GenomeMeta} from '../../pages/GeneViewerPage';
import {GenomeMeta} from "@components/interfaces/Genome";

const getAssembly = (genomeMeta: GenomeMeta, fastaBaseUrl: string) => ({
name: genomeMeta.assembly_name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { GeneMeta, GenomeMeta } from '../../pages/GeneViewerPage';
import {GeneMeta} from "@components/interfaces/Gene";
import {GenomeMeta} from "@components/interfaces/Genome";


const getDefaultSessionConfig = (
geneMeta: GeneMeta | null,
Expand All @@ -8,24 +10,26 @@ const getDefaultSessionConfig = (
) => {
if (!genomeMeta) {
console.log("Genome meta information not found");
return null; // Return null if genomeMeta is missing
return null;
}

const displayedRegions = geneMeta
? [
{
refName: geneMeta.seq_id,
start: geneMeta.start_position || 0,
end: geneMeta.end_position || 50000,
end: geneMeta.end_position || 1000,
reversed: true,
assemblyName: genomeMeta.assembly_name,
},
]
: [
{
refName: genomeMeta.assembly_name,
refName: genomeMeta.contigs[0].seq_id,
start: 0,
end: 5000000, // Adjust this default range
end: 1000,
reversed: true,
assemblyName: genomeMeta.assembly_name,
},
];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {GenomeMeta} from '../../pages/GeneViewerPage';
import {GenomeMeta} from "@components/interfaces/Genome";

const getTracks = (genomeMeta: GenomeMeta, gffBaseUrl: string) => [
{
Expand Down
44 changes: 7 additions & 37 deletions dataportal-app/src/components/pages/GeneViewerPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,8 @@ import GeneSearchForm from "@components/organisms/GeneSearch/GeneSearchForm";
import {fetchGenomeById} from "../../services/genomeService";
import {fetchGeneById, fetchGeneBySearch} from "../../services/geneService";
import {JBrowseApp} from "@jbrowse/react-app";

export interface GeneMeta {
id: number;
seq_id: string;
gene_name: string;
description: string;
strain_id: number;
strain: string;
assembly: string;
locus_tag: string;
cog: string | null;
kegg: string | null;
pfam: string | null;
interpro: string | null;
dbxref: string | null;
ec_number: string | null;
product: string | null;
start_position: number | null;
end_position: number | null;
annotations: Record<string, any> | null;
}

export interface GenomeMeta {
species: number;
id: number;
common_name: string;
isolate_name: string;
assembly_name: string;
assembly_accession: string;
fasta_file: string;
gff_file: string;
fasta_url: string;
gff_url: string;
}
import {GenomeMeta} from "@components/interfaces/Genome";
import {GeneMeta} from "@components/interfaces/Gene";

const GeneViewerPage: React.FC = () => {
const [geneMeta, setGeneMeta] = useState<GeneMeta | null>(null);
Expand Down Expand Up @@ -93,10 +61,12 @@ const GeneViewerPage: React.FC = () => {
}, [genomeMeta]);

const sessionConfig = useMemo(() => {
if (genomeMeta && geneMeta) {
if (genomeMeta) {
console.log('22222222222');
return getDefaultSessionConfig(geneMeta, genomeMeta, assembly, tracks);
} else if (genomeMeta) {
} else {
// Default session configuration if only genomeMeta is available
console.log('111111111111');
return {
name: "Default Genome View",
views: [
Expand All @@ -106,7 +76,7 @@ const GeneViewerPage: React.FC = () => {
tracks: tracks,
displayedRegions: [
{
refName: genomeMeta.assembly_name,
refName: 'Default assembly',
start: 0,
end: 5000000
}
Expand Down
1 change: 0 additions & 1 deletion dataportal-app/src/services/geneService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export const fetchGeneSearchResults = async (
selectedSpecies?: number [],
) => {
try {
console.log('2222222222')
const params = new URLSearchParams({
query: gene,
page: String(page),
Expand Down
2 changes: 1 addition & 1 deletion k8s-hl/dev/mett-dataportal-api-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
runAsUser: 7123
runAsGroup: 1347
containers:
- image: quay.io/microbiome-informatics/mett-dataportal-api:v0.0.29
- image: quay.io/microbiome-informatics/mett-dataportal-api:v0.0.30
imagePullPolicy: Always
name: mett-dataportal-api-dev
env:
Expand Down
2 changes: 1 addition & 1 deletion k8s-hl/dev/mett-dataportal-app-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
app: mett-dataportal-react-app-dev
spec:
containers:
- image: quay.io/microbiome-informatics/mett-dataportal-react-app:v0.0.29
- image: quay.io/microbiome-informatics/mett-dataportal-react-app:v0.0.30
imagePullPolicy: Always
name: mett-dataportal-react-app-dev
env:
Expand Down

0 comments on commit d1d2577

Please sign in to comment.