-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
3692 lines (3252 loc) · 224 KB
/
Copy pathindex.html
File metadata and controls
3692 lines (3252 loc) · 224 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" class="scroll-smooth">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bio-Line // CMLRE Initiative</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="database_search.js"></script>
<!-- Leaflet for maps -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<!-- Leaflet.heat for heatmap -->
<script src="https://unpkg.com/leaflet.heat@0.2.0/dist/leaflet-heat.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&family=Roboto+Mono:wght@400;500;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Inter', sans-serif;
background-color: #000000;
color: #e5e7eb;
--grid-color: rgba(255, 255, 255, 0.07);
background-image:
linear-gradient(var(--grid-color) 1px, transparent 1px),
linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
background-size: 30px 30px;
}
.font-mono {
font-family: 'Roboto Mono', monospace;
}
/* --- MODIFICATION 1: Position the Spline model as a background element on the right --- */
spline-viewer {
position: fixed; /* Fixed position relative to the viewport */
top: 0;
right: 0;
width: 50vw; /* Occupies the right half of the screen */
height: 100vh;
z-index: 0; /* Sits behind the content */
transform: scale(2.5); /* --- MODIFICATION: "Super zoom" the model by 2.5x --- */
transform-origin: center; /* Ensure it zooms from the center */
transition: opacity 0.3s ease; /* Smooth transition when hiding */
/* * --- MODIFICATION: Enable Model Interaction ---
* The 'pointer-events: none;' property has been removed.
* This allows mouse events (like scrolling to zoom, clicking, and dragging)
* to be captured by the Spline model instead of passing through it.
* Now, you can interact with the 3D model directly.
*/
}
.content-wrapper {
position: relative;
z-index: 1; /* Ensures content is on top of the spline model */
}
.card {
background-color: rgba(26, 26, 26, 0.6);
border: 1px solid #3f3f46;
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
}
.btn-primary {
background-color: transparent;
color: #ffffff;
transition: all 0.3s ease;
border: 1px solid #ffffff;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.btn-primary:hover {
background-color: #ffffff;
color: #000000;
}
.btn-primary:disabled {
color: #6b7280;
border-color: #3f3f46;
background-color: transparent;
cursor: not-allowed;
}
.btn-secondary {
background-color: transparent;
color: #a1a1aa;
border: 1px solid #3f3f46;
}
.btn-secondary:hover {
background-color: #27272a;
color: #ffffff;
}
.reveal {
opacity: 0;
transform: translateY(30px);
transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}
.reveal.visible {
opacity: 1;
transform: translateY(0);
}
.section-title {
color: #ffffff;
font-size: 1rem;
font-weight: 500;
letter-spacing: 0.2em;
text-transform: uppercase;
font-family: 'Roboto Mono', monospace;
}
.line {
height: 1px;
background-color: #27272a;
flex-grow: 1;
}
.text-scramble {
display: inline-block;
}
.blinking-cursor {
color: white;
animation: blink 1s step-end infinite;
}
@keyframes blink {
50% { opacity: 0; }
}
#reportModal.hidden, #chatbot-container.hidden {
display: none;
}
/* Custom scrollbar for results table */
#classificationResult::-webkit-scrollbar {
height: 6px;
}
#classificationResult::-webkit-scrollbar-track {
background: #000;
}
#classificationResult::-webkit-scrollbar-thumb {
background: #27272a;
border-radius: 3px;
}
#classificationResult::-webkit-scrollbar-thumb:hover {
background: #3f3f46;
}
/* Force Chart.js canvas text to be white */
canvas {
color: #ffffff !important;
}
</style>
</head>
<body class="antialiased">
<script type="module" src="https://unpkg.com/@splinetool/viewer@1.10.68/build/spline-viewer.js"></script>
<spline-viewer url="https://prod.spline.design/j-bDax7HxMeYiO4s/scene.splinecode"></spline-viewer>
<div class="content-wrapper">
<div id="homePage">
<header class="fixed top-0 left-0 right-0 z-50">
<nav class="container mx-auto px-6 py-4 flex justify-between items-center border-b border-gray-800 bg-black/50 backdrop-blur-md">
<div class="text-lg font-bold text-white tracking-widest"><a href="#">Bio-Line</a></div>
<div class="hidden md:flex items-center space-x-8 text-sm uppercase font-mono">
<a href="#problem" class="text-gray-400 hover:text-white transition">01_Problem</a>
<a href="#solution" class="text-gray-400 hover:text-white transition">02_Solution</a>
<a href="#tech" class="text-gray-400 hover:text-white transition">03_System</a>
</div>
<button id="loginBtn" class="btn-primary font-medium py-2 px-4 text-xs font-mono">Engage Platform</button>
</nav>
</header>
<main class="container mx-auto px-6">
<section class="min-h-screen flex flex-col justify-center items-start pt-20">
<div class="w-full lg:w-1/2">
<div class="text-left">
<h1 class="text-3xl md:text-5xl font-bold text-white leading-tight mb-4 font-mono">
<span class="text-scramble" data-text="AI-DRIVEN eDNA ANALYSIS"></span>
<span class="blinking-cursor">_</span>
</h1>
<p class="text-base text-gray-400 mb-8 max-w-lg">
A high-throughput pipeline to classify eukaryotic taxa and assess deep-sea biodiversity directly from raw environmental DNA, bypassing the limitations of conventional reference databases.
</p>
<div class="flex flex-wrap items-center gap-4">
<a href="#problem" class="btn-primary font-semibold py-3 px-6 text-sm">View Mission Brief</a>
<a href="https://youtu.be/i7P405rwkt0" target="_blank" rel="noopener noreferrer" class="inline-flex items-center gap-2 bg-red-600 hover:bg-red-700 text-white font-semibold py-3 px-6 text-sm rounded transition-all duration-300 group">
<svg class="w-5 h-5 group-hover:scale-110 transition-transform" viewBox="0 0 24 24" fill="currentColor">
<path d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/>
</svg>
Watch Live Demo
</a>
</div>
</div>
</div>
</section>
<section id="problem" class="py-24">
<div data-reveal class="flex items-center gap-4 mb-12"><span class="section-title text-gray-500">01</span><span class="section-title">Problem Statement</span><div class="line"></div></div>
<div class="grid md:grid-cols-2 gap-8">
<div class="card p-8 reveal rounded-lg" data-reveal><h3 class="text-xl font-bold text-white mb-4">// Incomplete Databases</h3><p class="text-gray-400">Deep-sea organisms are critically underrepresented in genetic reference databases. This data void results in misclassification, unassigned reads, and a fundamental underestimation of true biodiversity.</p></div>
<div class="card p-8 reveal rounded-lg" data-reveal style="transition-delay: 150ms"><h3 class="text-xl font-bold text-white mb-4">// Computational Bottlenecks</h3><p class="text-gray-400">Legacy bioinformatic pipelines are computationally expensive and inefficient for novel discovery. Their reliance on sequence alignment against flawed databases is a primary limiting factor.</p></div>
</div>
</section>
<section id="solution" class="py-24">
<div data-reveal class="flex items-center gap-4 mb-12"><span class="section-title text-gray-500">02</span><span class="section-title">Proposed Solution</span><div class="line"></div></div>
<div class="grid grid-cols-1 gap-8">
<div class="card p-8 md:p-12 reveal rounded-lg" data-reveal>
<p class="text-base text-gray-300 leading-relaxed">Our AI-driven pipeline leverages deep learning and unsupervised clustering to analyze eDNA without primary reliance on existing databases. The system is designed to:</p>
<ul class="mt-8 space-y-6 text-sm">
<li class="flex items-start"><span class="text-white mr-4 mt-1 font-mono">[+]</span><span><strong class="text-white font-semibold">CLASSIFY TAXA DIRECTLY:</strong> A fine-tuned DNA-BERT transformer model interprets raw sequence data, enabling classification without perfect database matches.</span></li>
<li class="flex items-start"><span class="text-white mr-4 mt-1 font-mono">[+]</span><span><strong class="text-white font-semibold">DISCOVER NOVEL SPECIES:</strong> Unsupervised clustering algorithms (DBSCAN, k-means) identify and group unknown sequences, flagging potential new taxa for targeted analysis.</span></li>
<li class="flex items-start"><span class="text-white mr-4 mt-1 font-mono">[+]</span><span><strong class="text-white font-semibold">GENERATE ECOLOGICAL INSIGHTS:</strong> Rapidly produce accurate estimations of species abundance and community structure to inform conservation and research priorities.</span></li>
</ul>
</div>
</div>
</section>
<section id="tech" class="py-24">
<div data-reveal class="flex items-center gap-4 mb-12"><span class="section-title text-gray-500">03</span><span class="section-title">System Architecture</span><div class="line"></div></div>
<div class="card p-8 flex justify-center items-center reveal rounded-lg" data-reveal>
<p class="text-center text-gray-400 max-w-4xl text-sm font-mono">SYSTEM INGESTS RAW eDNA DATA -> PREPROCESSING MODULE EXTRACTS 18S rRNA & COI MARKERS -> DATA IS VECTORIZED BY A FINE-TUNED DNA-BERT TRANSFORMER -> EMBEDDINGS ARE PROCESSED VIA DUAL PATHWAYS: [A] DEEP LEARNING FOR CLASSIFICATION, [B] UNSUPERVISED CLUSTERING FOR NOVELTY DETECTION -> OUTPUT GENERATION: TAXONOMIC GROUPING, ABUNDANCE ESTIMATION, ECOLOGICAL INSIGHTS.</p>
</div>
</section>
<div class="h-24"></div>
</main>
</div>
<div id="loginPage" class="hidden min-h-screen flex items-center justify-center p-4">
<div class="w-full max-w-sm">
<div class="card p-8 space-y-6 border border-[#27272a] rounded-lg">
<h2 class="text-lg font-bold text-center text-white tracking-widest font-mono">// AUTHENTICATION REQUIRED</h2>
<div>
<div class="flex border border-[#27272a] rounded-md overflow-hidden"><button id="userToggle" class="w-1/2 py-2 text-sm font-medium bg-white text-black">USER</button><button id="adminToggle" class="w-1/2 py-2 text-sm font-medium text-gray-400">ADMIN</button></div>
</div>
<form id="loginForm" class="space-y-4">
<div><label for="email" class="text-xs font-medium text-gray-400 font-mono">EMAIL_ADDR</label><input type="email" id="email" class="w-full mt-1 p-3 bg-black border border-[#27272a] rounded-md focus:ring-1 focus:ring-white focus:border-white outline-none text-sm" value="user@cmlre.gov"></div>
<div><label for="password" class="text-xs font-medium text-gray-400 font-mono">PASSWORD</label><input type="password" id="password" class="w-full mt-1 p-3 bg-black border border-[#27272a] rounded-md focus:ring-1 focus:ring-white focus:border-white outline-none" value="password"></div>
<button type="submit" class="w-full btn-primary font-bold py-3 px-4 text-xs rounded-md">EXECUTE LOGIN</button>
</form>
</div>
</div>
</div>
<div id="dashboardPage" class="hidden min-h-screen container mx-auto px-6 py-24">
<div class="flex justify-between items-center mb-8 border-b border-[#27272a] pb-4">
<h1 class="text-xl font-bold text-white tracking-widest font-mono">// ANALYSIS DASHBOARD</h1>
<button id="logoutBtn" class="text-gray-400 hover:text-white transition text-xs uppercase font-mono">LOGOUT</button>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
<div class="card p-6 border border-[#27272a] rounded-lg">
<h2 class="text-lg font-semibold text-white mb-4 font-mono">// SINGLE SEQUENCE ANALYSIS</h2>
<textarea id="dnaSequenceInput" rows="4" class="w-full p-3 bg-black border border-[#27272a] rounded-md focus:ring-1 focus:ring-white outline-none text-sm font-mono" placeholder="> Paste raw eDNA sequence here..."></textarea>
<div class="mt-4 text-right">
<button id="analyzeBtn" class="btn-primary font-bold py-2 px-5 text-xs rounded-md">INITIATE ANALYSIS</button>
</div>
</div>
<div class="card p-6 border border-[#27272a] rounded-lg">
<h2 class="text-lg font-semibold text-white mb-4 font-mono">// BATCH ANALYSIS (CSV/FASTA)</h2>
<p class="text-xs text-gray-400 mb-2">Upload a CSV file with 'sample_id' and 'sequence' columns, or a FASTA file with sequences.</p>
<!-- Format Examples -->
<details class="mb-2">
<summary class="text-xs text-blue-400 cursor-pointer hover:text-blue-300 transition">View format examples</summary>
<div class="mt-2 p-3 bg-black/50 border border-gray-800 rounded text-xs font-mono space-y-3">
<div>
<div class="text-gray-400 mb-1">CSV Format:</div>
<code class="text-green-400 block">sample_id,sequence<br>sample_1,ATCGATCGATCG<br>sample_2,GCTAGCTAGCTA</code>
</div>
<div>
<div class="text-gray-400 mb-1">FASTA Format:</div>
<code class="text-green-400 block">>sample_1<br>ATCGATCGATCG<br>>sample_2<br>GCTAGCTAGCTA</code>
</div>
</div>
</details>
<!-- Download Sample Files -->
<details class="mb-4">
<summary class="text-xs text-blue-400 cursor-pointer hover:text-blue-300 transition">Download sample</summary>
<div class="mt-2 p-3 bg-black/50 border border-gray-800 rounded text-xs space-y-2">
<div>
<a href="sample_sequences.csv" download class="text-blue-400 hover:text-blue-300 transition cursor-pointer">sample.csv (15 sequences)</a>
</div>
<div>
<a href="sample_sequences.fasta" download class="text-blue-400 hover:text-blue-300 transition cursor-pointer">sample.fasta (15 sequences)</a>
</div>
</div>
</details>
<input type="file" id="csvFileInput" class="hidden" accept=".csv,.fasta,.fa,.fna,.txt">
<button id="csvUploadBtn" class="w-full border border-dashed border-[#27272a] hover:border-white transition py-4 text-gray-400 text-sm rounded-md">
CLICK TO UPLOAD CSV/FASTA FILE
</button>
<div class="mt-4 space-y-3">
<div>
<label for="environmentType" class="text-xs font-medium text-gray-400 font-mono">ENVIRONMENT TYPE</label>
<input type="text" id="environmentType" placeholder="e.g. Hydrothermal Vent" class="w-full mt-1 p-3 bg-black border border-[#27272a] rounded-md focus:ring-1 focus:ring-white focus:border-white outline-none text-sm">
</div>
<div>
<label for="batchDepth" class="text-xs font-medium text-gray-400 font-mono">DEPTH (meters)</label>
<input type="number" id="batchDepth" step="1" placeholder="e.g. 2500" class="w-full mt-1 p-3 bg-black border border-[#27272a] rounded-md focus:ring-1 focus:ring-white focus:border-white outline-none text-sm">
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<label for="sampleLatitude" class="text-xs font-medium text-gray-400 font-mono">LATITUDE</label>
<input type="number" id="sampleLatitude" step="0.000001" placeholder="e.g. 20.5937" class="w-full mt-1 p-3 bg-black border border-[#27272a] rounded-md focus:ring-1 focus:ring-white focus:border-white outline-none text-sm">
</div>
<div>
<label for="sampleLongitude" class="text-xs font-medium text-gray-400 font-mono">LONGITUDE</label>
<input type="number" id="sampleLongitude" step="0.000001" placeholder="e.g. 88.2636" class="w-full mt-1 p-3 bg-black border border-[#27272a] rounded-md focus:ring-1 focus:ring-white focus:border-white outline-none text-sm">
</div>
</div>
</div>
<div class="mt-4 text-right">
<button id="batchAnalyzeBtn" class="btn-primary font-bold py-2 px-5 text-xs rounded-md" disabled>ANALYZE BATCH</button>
</div>
</div>
</div>
<div id="resultsSection" class="hidden">
<div class="mb-8 card border border-[#27272a] p-4 rounded-lg">
<h3 class="text-lg font-semibold text-white mb-4 font-mono">// PIPELINE STATUS</h3>
<div id="pipelineStatus" class="text-xs font-mono"></div>
</div>
<div id="markerResultsCard" class="hidden mb-8 card border border-[#27272a] p-6 rounded-lg">
<h3 class="text-lg font-semibold text-white mb-4 font-mono">// GENE MARKER DETECTION</h3>
<div id="markerResultsContent"></div>
</div>
<!-- Diversity Metrics Card -->
<div id="diversityMetricsCard" class="hidden mb-8 card border border-[#27272a] p-6 rounded-lg">
<h3 class="text-lg font-semibold text-white mb-4 font-mono">// DIVERSITY METRICS</h3>
<div id="diversityMetricsContent"></div>
</div>
<!-- Geographic Heatmap Card -->
<div id="heatmapCard" class="hidden mb-8 card border border-[#27272a] p-6 rounded-lg">
<div class="mb-4">
<h3 class="text-lg font-semibold text-white font-mono">// GEOGRAPHIC DISTRIBUTION HEATMAP</h3>
<p class="text-gray-400 text-xs mt-2">Spatial distribution of identified taxa based on collection coordinates</p>
</div>
<div id="heatmapContainer" class="bg-black/50 rounded-lg overflow-hidden" style="height: 500px; border: 1px solid #27272a;"></div>
<div id="heatmapLegend" class="mt-4 p-4 bg-black/30 border border-[#27272a] rounded-lg">
<div class="text-xs text-gray-400 mb-2 font-semibold">LEGEND</div>
<div class="flex items-center gap-4 flex-wrap">
<div class="flex items-center gap-2">
<div class="w-4 h-4 rounded-full" style="background: radial-gradient(circle, rgba(255,0,0,0.8) 0%, rgba(255,0,0,0) 70%);"></div>
<span class="text-xs text-gray-400">High Density</span>
</div>
<div class="flex items-center gap-2">
<div class="w-4 h-4 rounded-full" style="background: radial-gradient(circle, rgba(255,255,0,0.8) 0%, rgba(255,255,0,0) 70%);"></div>
<span class="text-xs text-gray-400">Medium Density</span>
</div>
<div class="flex items-center gap-2">
<div class="w-4 h-4 rounded-full" style="background: radial-gradient(circle, rgba(0,255,0,0.8) 0%, rgba(0,255,0,0) 70%);"></div>
<span class="text-xs text-gray-400">Low Density</span>
</div>
</div>
</div>
</div>
<!-- Clustering Analysis Card -->
<div id="clusteringCard" class="hidden mb-8 card border border-[#27272a] p-6 rounded-lg">
<div class="mb-4">
<h3 class="text-lg font-semibold text-white font-mono">// ORGANISM CLUSTERING ANALYSIS</h3>
<p class="text-gray-400 text-xs mt-2">Taxonomic relationships visualized using 2D UMAP clustering</p>
</div>
<div id="clusteringContent">
<div id="clusteringResults" class="hidden">
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
<!-- Stat Cards -->
<div class="bg-gradient-to-br from-blue-500/10 to-blue-600/5 border border-blue-500/30 rounded-lg p-4">
<div class="text-xs text-blue-400 uppercase tracking-wider mb-1">Total Clusters</div>
<div class="text-3xl font-bold text-white" id="totalClustersCount">0</div>
</div>
<div class="bg-gradient-to-br from-green-500/10 to-green-600/5 border border-green-500/30 rounded-lg p-4">
<div class="text-xs text-green-400 uppercase tracking-wider mb-1">Clustered</div>
<div class="text-3xl font-bold text-white" id="clusteredCount">0</div>
</div>
<div class="bg-gradient-to-br from-yellow-500/10 to-yellow-600/5 border border-yellow-500/30 rounded-lg p-4">
<div class="text-xs text-yellow-400 uppercase tracking-wider mb-1">Novel/Outliers</div>
<div class="text-3xl font-bold text-white" id="novelClusterCount">0</div>
</div>
</div>
<!-- Cluster Scatter Plot -->
<div class="mb-6">
<h4 class="text-sm font-semibold text-white mb-3 font-mono">Cluster Distribution (2D UMAP)</h4>
<div class="bg-black/50 p-4 rounded-lg border border-[#27272a]">
<canvas id="clusterScatterChart" height="300"></canvas>
</div>
</div>
<!-- Cluster Details -->
<div id="clusterDetails" class="space-y-3"></div>
</div>
</div>
</div>
<!-- Taxonomic Classification Results - Full Width -->
<div class="mb-8 card p-6 border border-[#27272a] rounded-lg">
<div class="flex justify-between items-center flex-wrap gap-2 mb-4">
<h3 class="text-lg font-semibold text-white font-mono">// TAXONOMIC CLASSIFICATION RESULTS</h3>
<div class="flex items-center gap-2">
<button id="verifyDatabaseBtn" class="hidden btn-secondary font-bold py-2 px-4 text-xs rounded-md">
🔍 Verify Novel Species
</button>
<button id="exportResultsBtn" class="hidden btn-secondary font-bold py-2 px-4 text-xs rounded-md">Export CSV</button>
</div>
</div>
<div id="classificationResult" class="text-sm">
<p class="text-gray-500">Results will appear here after analysis.</p>
</div>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<div class="lg:col-span-2 space-y-8">
<div id="insightsCard" class="card p-6 border border-[#27272a] rounded-lg">
<div class="flex justify-between items-center flex-wrap gap-2 mb-4">
<h3 class="text-lg font-semibold text-white font-mono">// ECOLOGICAL INSIGHTS REPORT</h3>
<div class="flex items-center gap-2">
<button id="chatBtn" class="hidden btn-secondary font-bold py-2 px-5 text-xs rounded-md">Chat with AI</button>
<button id="generateReportBtn" class="hidden btn-primary font-bold py-2 px-5 text-xs rounded-md">Generate Report</button>
</div>
</div>
<div id="insightsResult" class="space-y-6 text-sm">
<p class="text-gray-500">Ecological insights will be generated after batch analysis is complete.</p>
</div>
</div>
</div>
<div class="space-y-8">
<div class="card p-6 border border-[#27272a] rounded-lg">
<h3 class="text-lg font-semibold text-white mb-4 font-mono">// TAXA ABUNDANCE</h3>
<canvas id="abundanceChart"></canvas>
</div>
<div class="card p-6 border border-[#27272a] rounded-lg">
<h3 class="text-lg font-semibold text-white mb-4 font-mono">// NOVELTY DETECTION</h3>
<div id="noveltyResult" class="text-sm p-4 bg-black border border-[#27272a] rounded-md"></div>
</div>
</div>
</div>
</div>
<div class="h-24"></div>
</div>
</div>
<div id="reportModal" class="hidden fixed inset-0 bg-black bg-opacity-70 z-50 flex items-center justify-center p-4">
<div class="card w-full max-w-md p-6 text-center border border-[#27272a] rounded-lg">
<h2 class="text-lg font-bold text-white mb-4 font-mono">// Select Report Type</h2>
<p class="text-sm text-gray-400 mb-6">Choose the type of report you would like to generate and download.</p>
<div id="modal-loader" class="hidden mb-4">
<div class="flex justify-center items-center space-x-2">
<svg class="animate-spin h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>
<span class="text-sm text-gray-400">Generating detailed report... this may take a moment.</span>
</div>
</div>
<div id="modal-buttons" class="space-y-4">
<button id="downloadSummaryReportBtn" class="w-full btn-primary font-bold py-3 text-sm rounded-md">Download Summary Report</button>
<button id="downloadDetailedReportBtn" class="w-full btn-secondary font-bold py-3 text-sm rounded-md">Download Detailed Report</button>
</div>
<button id="closeModalBtn" class="mt-6 text-sm text-gray-500 hover:text-white">Cancel</button>
</div>
</div>
<!-- Disclaimer Modal -->
<div id="disclaimerModal" class="hidden fixed inset-0 bg-black bg-opacity-80 z-[200] flex items-center justify-center p-4">
<div class="card w-full max-w-lg p-8 border border-yellow-500/50 rounded-lg relative overflow-hidden">
<!-- Warning stripe decoration -->
<div class="absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-yellow-500 via-orange-500 to-yellow-500"></div>
<!-- Warning icon -->
<div class="flex justify-center mb-4">
<div class="w-16 h-16 bg-yellow-500/20 rounded-full flex items-center justify-center">
<svg class="w-10 h-10 text-yellow-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
</svg>
</div>
</div>
<h2 class="text-xl font-bold text-center text-yellow-400 mb-4 font-mono">// DEMO MODE NOTICE</h2>
<div class="bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-4 mb-6">
<p class="text-gray-300 text-sm leading-relaxed text-center">
The results displayed are currently based on <span class="text-yellow-400 font-semibold">mock data</span> and are <span class="text-yellow-400 font-semibold">not generated by trained Transformer-based models</span>.
</p>
<p class="text-gray-400 text-sm mt-3 text-center">
Real-time model deployment is temporarily disabled due to <span class="text-orange-400">high GPU inference costs</span>.
</p>
</div>
<div class="flex flex-col items-center gap-4">
<a href="https://youtu.be/i7P405rwkt0" target="_blank" rel="noopener noreferrer" class="inline-flex items-center gap-2 bg-red-600 hover:bg-red-700 text-white font-semibold py-3 px-6 text-sm rounded-lg transition-all duration-300 group">
<svg class="w-5 h-5 group-hover:scale-110 transition-transform" viewBox="0 0 24 24" fill="currentColor">
<path d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/>
</svg>
Watch Live Demo on YouTube
</a>
<button id="closeDisclaimerBtn" class="btn-primary font-bold py-3 px-8 text-sm rounded-lg">
I Understand, Continue to Demo
</button>
</div>
<p class="text-gray-500 text-xs text-center mt-4">
This demo showcases the platform's capabilities with simulated data.
</p>
</div>
</div>
<div id="chatbot-container" class="hidden fixed bottom-5 right-5 w-full max-w-sm h-[600px] z-[100] flex flex-col card p-0 overflow-hidden shadow-2xl border border-[#27272a] rounded-lg">
<div class="flex justify-between items-center p-4 border-b border-[#27272a] bg-black/80">
<h3 class="font-bold text-white font-mono">// AI Ecologist Assistant</h3>
<button id="closeChatbotBtn" class="text-gray-500 hover:text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /></svg>
</button>
</div>
<div id="chat-messages" class="flex-1 p-4 overflow-y-auto space-y-4 bg-black">
</div>
<div class="p-4 border-t border-[#27272a] bg-black/80">
<form id="chat-form" class="flex items-center gap-2">
<input type="text" id="chat-input" class="w-full p-3 bg-black border border-[#27272a] rounded-md focus:ring-1 focus:ring-white outline-none text-sm" placeholder="Ask about the insights...">
<button type="submit" class="btn-primary p-3 rounded-md shrink-0">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-8.707l-3-3a1 1 0 00-1.414 1.414L10.586 9H7a1 1 0 100 2h3.586l-1.293 1.293a1 1 0 101.414 1.414l3-3a1 1 0 000-1.414z" clip-rule="evenodd" /></svg>
</button>
</form>
</div>
</div>
<script type="module">
// Note: Three.js import is no longer needed
// import * as THREE from 'three';
document.addEventListener('DOMContentLoaded', () => {
// --- Background 3D DNA Model (Three.js) ---
// This entire section has been commented out as it is replaced by the Spline model
/*
const bgCanvas = document.getElementById('bg-dna-canvas');
if (bgCanvas) {
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x000000, 10, 40);
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer({ canvas: bgCanvas, alpha: true, antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
const ambientLight = new THREE.AmbientLight(0x40a0ff, 0.5);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0x80c0ff, 1);
directionalLight.position.set(5, 5, 5);
scene.add(directionalLight);
const group = new THREE.Group();
group.rotation.x = Math.PI / 8;
group.rotation.y = -Math.PI / 4;
const helixRadius = 3;
const helixHeight = 40;
const turnCount = 10;
const basePairs = 150;
const baseColors = [0x00aaff, 0x0088cc, 0x006699];
const createStrand = () => {
const curve = new THREE.CatmullRomCurve3(
Array.from({ length: 200 }, (_, i) => {
const t = (i / 199) * helixHeight;
return new THREE.Vector3(
helixRadius * Math.cos(t * turnCount * Math.PI / helixHeight),
t - helixHeight / 2,
helixRadius * Math.sin(t * turnCount * Math.PI / helixHeight)
);
})
);
const geometry = new THREE.TubeGeometry(curve, 100, 0.15, 12, false);
const material = new THREE.MeshPhongMaterial({ color: 0x0055aa, shininess: 30 });
return new THREE.Mesh(geometry, material);
};
const strand1 = createStrand();
const strand2 = createStrand();
strand2.rotation.y = Math.PI;
group.add(strand1, strand2);
for (let i = 0; i < basePairs; i++) {
const t = (i / (basePairs - 1)) * helixHeight;
const y = t - helixHeight / 2;
const angle = t * turnCount * Math.PI / helixHeight;
const start = new THREE.Vector3(helixRadius * Math.cos(angle), y, helixRadius * Math.sin(angle));
const end = new THREE.Vector3(helixRadius * Math.cos(angle + Math.PI), y, helixRadius * Math.sin(angle + Math.PI));
const distance = start.distanceTo(end);
const position = start.clone().add(end).divideScalar(2);
const cylinderGeometry = new THREE.CylinderGeometry(0.08, 0.08, distance, 8);
const cylinderMaterial = new THREE.MeshPhongMaterial({
color: baseColors[i % baseColors.length],
emissive: baseColors[i % baseColors.length],
emissiveIntensity: 0.3
});
const cylinder = new THREE.Mesh(cylinderGeometry, cylinderMaterial);
cylinder.position.copy(position);
cylinder.lookAt(end);
cylinder.rotateX(Math.PI / 2);
group.add(cylinder);
}
scene.add(group);
const initialCameraZ = 40;
const finalCameraZ = 5;
camera.position.z = initialCameraZ;
const animate = () => {
requestAnimationFrame(animate);
group.rotation.y += 0.0005;
renderer.render(scene, camera);
};
animate();
function handleScrollAnimation() {
const scrollY = window.scrollY;
const animationScrollHeight = window.innerHeight;
const scrollFraction = Math.min(scrollY / animationScrollHeight, 1);
const easedFraction = 1 - Math.pow(1 - scrollFraction, 3);
camera.position.z = THREE.MathUtils.lerp(initialCameraZ, finalCameraZ, easedFraction);
camera.position.y = THREE.MathUtils.lerp(0, helixHeight / 4, easedFraction);
group.rotation.y = THREE.MathUtils.lerp(-Math.PI / 4, Math.PI, easedFraction);
group.rotation.x = THREE.MathUtils.lerp(Math.PI / 8, -Math.PI / 16, easedFraction);
}
window.addEventListener('scroll', handleScrollAnimation, { passive: true });
window.addEventListener('resize', () => {
const newWidth = window.innerWidth;
const newHeight = window.innerHeight;
camera.aspect = newWidth / newHeight;
camera.updateProjectionMatrix();
renderer.setSize(newWidth, newHeight);
});
}
*/
// --- Text Scramble Effect ---
class TextScrambleEffect {
constructor(el) { this.el = el; this.chars = '!<>-_\\/[]{}—=+*^?#________'; this.update = this.update.bind(this); }
setText(newText) {
const oldText = this.el.innerText;
const length = Math.max(oldText.length, newText.length);
const promise = new Promise((resolve) => this.resolve = resolve);
this.queue = [];
for (let i = 0; i < length; i++) {
const from = oldText[i] || ''; const to = newText[i] || '';
const start = Math.floor(Math.random() * 40); const end = start + Math.floor(Math.random() * 40);
this.queue.push({ from, to, start, end });
}
cancelAnimationFrame(this.frameRequest); this.frame = 0; this.update(); return promise;
}
update() {
let output = ''; let complete = 0;
for (let i = 0, n = this.queue.length; i < n; i++) {
let { from, to, start, end, char } = this.queue[i];
if (this.frame >= end) { complete++; output += to; }
else if (this.frame >= start) {
if (!char || Math.random() < 0.28) { char = this.randomChar(); this.queue[i].char = char; }
output += `<span class="opacity-50">${char}</span>`;
} else { output += from; }
}
this.el.innerHTML = output;
if (complete === this.queue.length) { this.resolve(); }
else { this.frameRequest = requestAnimationFrame(this.update); this.frame++; }
}
randomChar() { return this.chars[Math.floor(Math.random() * this.chars.length)]; }
}
const scrambleElements = document.querySelectorAll('.text-scramble');
scrambleElements.forEach(el => {
const fx = new TextScrambleEffect(el); const originalText = el.dataset.text;
setTimeout(() => {
el.nextElementSibling.style.display = 'inline-block';
fx.setText(originalText).then(() => { setTimeout(() => { el.nextElementSibling.style.display = 'none'; }, 1000); });
}, 500);
});
// --- Scroll Reveal Effect ---
const revealElements = document.querySelectorAll('[data-reveal]');
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) { entry.target.classList.add('visible'); observer.unobserve(entry.target); }
});
}, { threshold: 0.1 });
revealElements.forEach(el => { observer.observe(el); });
// --- Page Navigation and UI Logic ---
const homePage = document.getElementById('homePage');
const loginPage = document.getElementById('loginPage');
const dashboardPage = document.getElementById('dashboardPage');
const loginBtn = document.getElementById('loginBtn');
const loginForm = document.getElementById('loginForm');
const logoutBtn = document.getElementById('logoutBtn');
const userToggle = document.getElementById('userToggle');
const adminToggle = document.getElementById('adminToggle');
const splineViewer = document.querySelector('spline-viewer');
loginBtn.addEventListener('click', () => {
homePage.style.display = 'none';
loginPage.style.display = 'flex';
if (splineViewer) splineViewer.style.display = 'none'; // Hide 3D model for performance
});
// Disclaimer modal elements
const disclaimerModal = document.getElementById('disclaimerModal');
const closeDisclaimerBtn = document.getElementById('closeDisclaimerBtn');
loginForm.addEventListener('submit', (e) => {
e.preventDefault();
const email = document.getElementById('email').value;
const isAdminActive = adminToggle.classList.contains('bg-white');
if (isAdminActive) {
window.location.href = './admin.html';
} else {
loginPage.style.display = 'none';
// Show disclaimer modal first
disclaimerModal.classList.remove('hidden');
if (splineViewer) splineViewer.style.display = 'none'; // Keep 3D model hidden on dashboard
}
});
// Close disclaimer and show dashboard
closeDisclaimerBtn.addEventListener('click', () => {
disclaimerModal.classList.add('hidden');
dashboardPage.style.display = 'block';
});
logoutBtn.addEventListener('click', () => {
dashboardPage.style.display = 'none';
homePage.style.display = 'block';
if (splineViewer) splineViewer.style.display = 'block'; // Show 3D model again on home page
document.getElementById('resultsSection').classList.add('hidden');
document.getElementById('dnaSequenceInput').value = '';
// Hide chat elements on logout
chatBtn.classList.add('hidden');
chatbotContainer.classList.add('hidden');
chatMessages.innerHTML = '';
});
const setToggle = (active, inactive) => {
active.classList.add('bg-white', 'text-black');
active.classList.remove('text-gray-400');
inactive.classList.remove('bg-white', 'text-black');
inactive.classList.add('text-gray-400');
};
userToggle.addEventListener('click', () => setToggle(userToggle, adminToggle));
adminToggle.addEventListener('click', () => setToggle(adminToggle, userToggle));
// ===============================================================
// ================== API INTEGRATION STARTS HERE ================
// ===============================================================
const analyzeBtn = document.getElementById('analyzeBtn');
const batchAnalyzeBtn = document.getElementById('batchAnalyzeBtn');
const csvFileInput = document.getElementById('csvFileInput');
const csvUploadBtn = document.getElementById('csvUploadBtn');
const resultsSection = document.getElementById('resultsSection');
const pipelineStatusEl = document.getElementById('pipelineStatus');
const markerResultsCard = document.getElementById('markerResultsCard');
const markerResultsContent = document.getElementById('markerResultsContent');
const classificationResultEl = document.getElementById('classificationResult');
const noveltyResultEl = document.getElementById('noveltyResult');
const insightsResultEl = document.getElementById('insightsResult');
const analyzeButtonText = 'INITIATE ANALYSIS';
const generateReportBtn = document.getElementById('generateReportBtn');
const reportModal = document.getElementById('reportModal');
const closeModalBtn = document.getElementById('closeModalBtn');
const downloadSummaryReportBtn = document.getElementById('downloadSummaryReportBtn');
const downloadDetailedReportBtn = document.getElementById('downloadDetailedReportBtn');
const modalLoader = document.getElementById('modal-loader');
const modalButtons = document.getElementById('modal-buttons');
// --- Chatbot elements ---
const chatBtn = document.getElementById('chatBtn');
const chatbotContainer = document.getElementById('chatbot-container');
const closeChatbotBtn = document.getElementById('closeChatbotBtn');
const chatForm = document.getElementById('chat-form');
const chatInput = document.getElementById('chat-input');
const chatMessages = document.getElementById('chat-messages');
// ===============================================================
// =============== MOCK DATA GENERATION SYSTEM ==================
// ===============================================================
// This website uses mock data for demonstration purposes.
// No external APIs are called - all results are generated locally.
const MOCK_MODE = true; // All APIs are replaced with mock functions
// Mock species database for generating fake classifications
const MOCK_SPECIES_DATABASE = [
{ kingdom: 'Eukaryota', phylum: 'Chordata', class: 'Actinopterygii', order: 'Perciformes', family: 'Serranidae', genus: 'Epinephelus', species: 'Epinephelus malabaricus', common: 'Malabar Grouper' },
{ kingdom: 'Eukaryota', phylum: 'Arthropoda', class: 'Malacostraca', order: 'Decapoda', family: 'Penaeidae', genus: 'Penaeus', species: 'Penaeus monodon', common: 'Giant Tiger Prawn' },
{ kingdom: 'Eukaryota', phylum: 'Mollusca', class: 'Cephalopoda', order: 'Octopoda', family: 'Octopodidae', genus: 'Octopus', species: 'Octopus vulgaris', common: 'Common Octopus' },
{ kingdom: 'Eukaryota', phylum: 'Cnidaria', class: 'Anthozoa', order: 'Scleractinia', family: 'Acroporidae', genus: 'Acropora', species: 'Acropora cervicornis', common: 'Staghorn Coral' },
{ kingdom: 'Eukaryota', phylum: 'Annelida', class: 'Polychaeta', order: 'Phyllodocida', family: 'Nereididae', genus: 'Nereis', species: 'Nereis virens', common: 'Sandworm' },
{ kingdom: 'Eukaryota', phylum: 'Echinodermata', class: 'Asteroidea', order: 'Forcipulatida', family: 'Asteriidae', genus: 'Asterias', species: 'Asterias rubens', common: 'Common Starfish' },
{ kingdom: 'Eukaryota', phylum: 'Porifera', class: 'Demospongiae', order: 'Haplosclerida', family: 'Chalinidae', genus: 'Haliclona', species: 'Haliclona oculata', common: 'Eyed Sponge' },
{ kingdom: 'Eukaryota', phylum: 'Chordata', class: 'Chondrichthyes', order: 'Carcharhiniformes', family: 'Carcharhinidae', genus: 'Carcharhinus', species: 'Carcharhinus melanopterus', common: 'Blacktip Reef Shark' },
{ kingdom: 'Eukaryota', phylum: 'Mollusca', class: 'Bivalvia', order: 'Ostreoida', family: 'Ostreidae', genus: 'Crassostrea', species: 'Crassostrea gigas', common: 'Pacific Oyster' },
{ kingdom: 'Eukaryota', phylum: 'Arthropoda', class: 'Maxillopoda', order: 'Calanoida', family: 'Calanidae', genus: 'Calanus', species: 'Calanus finmarchicus', common: 'Copepod' },
{ kingdom: 'Eukaryota', phylum: 'Cnidaria', class: 'Hydrozoa', order: 'Siphonophorae', family: 'Physaliidae', genus: 'Physalia', species: 'Physalia physalis', common: 'Portuguese Man o War' },
{ kingdom: 'Eukaryota', phylum: 'Chordata', class: 'Mammalia', order: 'Cetacea', family: 'Delphinidae', genus: 'Tursiops', species: 'Tursiops truncatus', common: 'Bottlenose Dolphin' },
{ kingdom: 'Eukaryota', phylum: 'Chordata', class: 'Reptilia', order: 'Testudines', family: 'Cheloniidae', genus: 'Chelonia', species: 'Chelonia mydas', common: 'Green Sea Turtle' },
{ kingdom: 'Eukaryota', phylum: 'Ctenophora', class: 'Tentaculata', order: 'Lobata', family: 'Mnemiidae', genus: 'Mnemiopsis', species: 'Mnemiopsis leidyi', common: 'Sea Walnut' },
{ kingdom: 'Eukaryota', phylum: 'Arthropoda', class: 'Merostomata', order: 'Xiphosura', family: 'Limulidae', genus: 'Limulus', species: 'Limulus polyphemus', common: 'Horseshoe Crab' }
];
// Mock novel species that don't exist in databases
const MOCK_NOVEL_SPECIES = [
{ kingdom: 'Eukaryota', phylum: 'Arthropoda', class: 'Malacostraca', order: 'Decapoda', family: 'Unknown', genus: 'Novacaris', species: 'Novacaris abyssalis' },
{ kingdom: 'Eukaryota', phylum: 'Annelida', class: 'Polychaeta', order: 'Unknown', family: 'Unknown', genus: 'Cryptoworm', species: 'Cryptoworm thermophilus' },
{ kingdom: 'Eukaryota', phylum: 'Cnidaria', class: 'Anthozoa', order: 'Actiniaria', family: 'Unknown', genus: 'Abyssanemone', species: 'Abyssanemone gigantea' }
];
// Generate a unique identifier for novel species
function generateMockUID() {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
let uid = 'BLC-';
for (let i = 0; i < 8; i++) {
uid += chars.charAt(Math.floor(Math.random() * chars.length));
}
return uid;
}
// Mock gene marker detection
async function mockGeneMarkerApi(sequence) {
// Simulate API delay
await new Promise(resolve => setTimeout(resolve, 300 + Math.random() * 400));
const markerTypes = ['COI', '18S rRNA'];
const selectedMarker = markerTypes[Math.floor(Math.random() * markerTypes.length)];
// Generate mock prediction
const startPos = Math.floor(Math.random() * Math.max(1, sequence.length - 200));
const markerSequence = sequence.substring(startPos, Math.min(startPos + 180, sequence.length));
return {
predictions: [{
label: selectedMarker,
sequence: markerSequence,
confidence: 0.85 + Math.random() * 0.14,
start: startPos,
end: startPos + markerSequence.length
}]
};
}
// Mock DNABERT classification
async function mockDnabertApi(sequence, markerType = 'Unknown') {
// Simulate API delay
await new Promise(resolve => setTimeout(resolve, 400 + Math.random() * 600));
// 20% chance of being a novel species
const isNovel = Math.random() < 0.20;
let classification;
if (isNovel) {
classification = MOCK_NOVEL_SPECIES[Math.floor(Math.random() * MOCK_NOVEL_SPECIES.length)];
} else {
classification = MOCK_SPECIES_DATABASE[Math.floor(Math.random() * MOCK_SPECIES_DATABASE.length)];
}
const uid = isNovel ? generateMockUID() : null;
return {
classification: {
Kingdom: classification.kingdom,
Phylum: classification.phylum,
Class: classification.class,
Order: classification.order,
Family: classification.family,
Genus: classification.genus,
Species: classification.species
},
is_novel: isNovel,
uid: uid,
message: isNovel ? 'Novel species detected - not found in reference databases' : 'Species classified successfully',
// Backwards compatible fields
predicted_taxa: classification.species,
predicted_level: 'Species',
predicted_group: classification.kingdom,
taxa_confidence: isNovel ? 0.6 + Math.random() * 0.2 : 0.85 + Math.random() * 0.14,
group_confidence: 0.9 + Math.random() * 0.09,
novelty_status: isNovel ? `Novel Species - UID: ${uid}` : 'Known Species',
kingdom: classification.kingdom,
phylum: classification.phylum,
class: classification.class,
order: classification.order,
family: classification.family,
genus: classification.genus,
species: classification.species
};
}
// Mock ecological insights generation
async function mockGenerateInsights(results) {
// Simulate API delay
await new Promise(resolve => setTimeout(resolve, 1500 + Math.random() * 1000));
const numSpecies = new Set(results.map(r => r.species)).size;
const numNovel = results.filter(r => r.is_novel).length;
// Group by phylum
const phylumCounts = results.reduce((acc, r) => {
const p = r.phylum || 'Unknown';
acc[p] = (acc[p] || 0) + 1;
return acc;
}, {});
const dominantPhylum = Object.entries(phylumCounts).sort((a, b) => b[1] - a[1])[0]?.[0] || 'Unknown';
return {
summary: {
title: 'Ecological Summary',
insight: `This eDNA analysis identified ${results.length} sequences representing ${numSpecies} unique taxa across multiple marine phyla. The community shows ${numNovel > 0 ? 'notable biodiversity with ' + numNovel + ' potentially novel species detected' : 'typical composition for the sampled environment'}. The presence of diverse taxonomic groups indicates a functioning ecosystem with multiple trophic levels represented.`
},
biodiversity_assessment: {
title: 'Biodiversity Assessment',
insight: `The sample demonstrates ${numSpecies > 10 ? 'high' : numSpecies > 5 ? 'moderate' : 'low'} species richness with ${numSpecies} identified taxa. Species evenness appears ${Math.random() > 0.5 ? 'relatively balanced' : 'dominated by a few abundant taxa'}, suggesting ${Math.random() > 0.5 ? 'a stable community structure' : 'possible environmental pressures affecting community dynamics'}.`,
richness_value: numSpecies,
evenness_category: numSpecies > 8 ? 'High' : numSpecies > 4 ? 'Moderate' : 'Low'
},
community_structure: {
title: 'Community Structure',
insight: `The community is dominated by ${dominantPhylum}, which comprises ${((phylumCounts[dominantPhylum] / results.length) * 100).toFixed(1)}% of identified sequences. This taxonomic composition is consistent with ${Math.random() > 0.5 ? 'a healthy benthic community' : 'deep-sea environmental conditions'}. The presence of multiple phyla indicates ecological complexity.`,
major_groups: phylumCounts
},
dominant_taxa: {
title: 'Dominant Taxa & Significance',
insight: `The most abundant taxa belong to ${dominantPhylum}, which play crucial roles in marine ecosystems. These organisms typically serve as ${dominantPhylum === 'Arthropoda' ? 'important links in the food web, serving as both predators and prey' : dominantPhylum === 'Chordata' ? 'apex or meso-predators regulating lower trophic levels' : 'foundation species providing habitat structure'}. Their presence indicates ${Math.random() > 0.5 ? 'productive ecosystem conditions' : 'stable environmental parameters'}.`
},
trophic_levels: {
title: 'Ecological Roles & Food Web',
insight: `The identified taxa span multiple trophic levels, from ${phylumCounts['Porifera'] ? 'filter feeders (sponges)' : 'primary consumers'} to ${phylumCounts['Chordata'] ? 'apex predators (fish, mammals)' : 'secondary consumers'}. This trophic diversity suggests a complex food web with energy flow through multiple pathways. The presence of detritivores and filter feeders indicates active nutrient cycling.`
},
bioindicators: {
title: 'Bioindicator Analysis',
insight: `Several identified taxa serve as bioindicators for environmental conditions. ${phylumCounts['Cnidaria'] ? 'Cnidarians (corals) indicate water quality and temperature stability. ' : ''}${phylumCounts['Echinodermata'] ? 'Echinoderms suggest good oxygen levels and sediment quality. ' : ''}${numNovel > 0 ? 'The detection of potentially novel species highlights the importance of this habitat for undiscovered biodiversity and warrants further investigation.' : 'The absence of pollution-indicator species suggests relatively healthy environmental conditions.'}`
}
};
}
// Mock chatbot response
async function mockChatbotResponse(question, insightsData) {
await new Promise(resolve => setTimeout(resolve, 800 + Math.random() * 700));
const questionLower = question.toLowerCase();
if (questionLower.includes('novel') || questionLower.includes('new species')) {
return "Based on this analysis, several sequences were flagged as potentially **novel species** not found in current reference databases. These specimens warrant further investigation through morphological examination and additional molecular markers. Novel species detection is an exciting aspect of eDNA analysis!";
}
if (questionLower.includes('biodiversity') || questionLower.includes('diversity')) {
return `The biodiversity assessment shows **${insightsData?.biodiversity_assessment?.evenness_category || 'moderate'} evenness** with ${insightsData?.biodiversity_assessment?.richness_value || 'multiple'} taxa identified. Higher diversity typically indicates a more resilient ecosystem capable of withstanding environmental perturbations.`;
}
if (questionLower.includes('dominant') || questionLower.includes('abundant')) {
return "The dominant taxa in this sample play crucial ecological roles. Their abundance reflects their adaptation to local conditions and their position in the food web. Monitoring dominant species over time helps track ecosystem health.";
}
if (questionLower.includes('threat') || questionLower.includes('conservation')) {
return "Based on the community composition, key conservation considerations include: **1)** Protecting habitat complexity for diverse species, **2)** Monitoring water quality parameters, **3)** Establishing baseline data for detecting future changes, and **4)** Further investigating potentially novel species.";
}
if (questionLower.includes('food web') || questionLower.includes('trophic')) {
return "The identified taxa span multiple **trophic levels**, from filter feeders and detritivores at the base to predatory species higher up. This complexity indicates a healthy ecosystem with efficient energy transfer between levels.";
}
return `Great question! Based on the ecological analysis, I can tell you that this sample shows interesting patterns of marine biodiversity. The community composition includes representatives from multiple phyla, indicating ecological complexity. Would you like to know more about any specific aspect - perhaps the **dominant species**, **diversity metrics**, or **conservation implications**?`;
}
// ===============================================================
// ============= END MOCK DATA GENERATION SYSTEM ================
// ===============================================================
let parsedCsvData = [];
let currentInsightsData = null;
let detailedReportData = [];
let clusteringData = null; // Store clustering results
let clusterScatterChart = null; // Chart instance
let currentPage = 1; // Pagination state for results table
const resultsPerPage = 5; // Results per page
let clusterPage = 1; // Pagination for cluster details
const clustersPerPage = 3; // Clusters per page
let heatmapInstance = null; // Store Leaflet map instance
let locationData = []; // Store location and taxonomic data
// Define changeClusterPage globally so onclick handlers can access it
window.changeClusterPage = function(page) {
clusterPage = page;
if (window.clusteringData && window.clusteringData.clusters) {
displayClusterDetails(window.clusteringData.clusters, window.clusteringData.results);
}
};
// ===============================================================
// ============== GEOGRAPHIC HEATMAP FUNCTIONALITY ===============
// ===============================================================
function initializeHeatmap() {
const container = document.getElementById('heatmapContainer');
if (!container) return;
// Clear any existing map
if (heatmapInstance) {
heatmapInstance.remove();