Wang Zhao-Hui

Nie Xiang-Ping

Jiang Shi-Jun

Zhang Jian-Gang

Cao Yu

Zhang Yu-Juan

Wang Da-Zhi

Source and profile of paralytic shellfish poisoning toxins in shellfish in Daya Bay, South China Sea

Keywords: Paralytic shellfish poisoning (PSP) toxins, Alexandrium tamarense, Cyst, Phytoplankton, Algal toxins, Toxicity, South China Sea

Changes in cell density and cyst flux of Alexandrium tamarense, paralytic shellfish poisoning (PSP) toxin contents in shellfishes, and environmental parameters were measured in two stations in Daya Bay, South China Sea from March 2005 to July 2006. Vegetative cells of A. tamarense occurred sporadically; however, they presented abundantly during the winter months. Meanwhile, cyst flux reached its maximum level just following the peak abundance of motile cells. The PSP contents in shellfish were generally low, but higher in winter with the maximum of 14 015 µg STX equiv./kg. The majority of toxins were found in digestive glands, with a maximum of 66 227 µg STX equiv./kg. There were significant positive relationships between toxin level and vegetative cell density and cyst flux. This indicates that vegetative cells and cysts of Alexandrium significantly influenced PSP level, and could be an important source of PSP toxins in shellfish during winter.

Introduction

Paralytic shellfish poisoning (PSP) toxins are biotoxins produced by micro-phytoplankton that can accumulate in filter-feeding shellfish [START_REF] Shumway | A review of the effects of algal blooms onshellfish and aquaculture[END_REF][START_REF] Hallegraeff | Harmful algal blooms: a global overview[END_REF]. Subsequent ingestion of contaminated shellfish by humans can result in serious illness or even death. The incidence of human poisoning has increased markedly since the early 1970s [START_REF] Hallegraeff | Harmful algal blooms: a global overview[END_REF]. Species within the dinoflagellate genus Alexandrium, such as A. tamarense and A. catenella, have been known as important producers of PSP toxins.

Resting cysts of these toxic dinoflagellates have been shown to contain toxins [START_REF] Bravo | PSP toxin composition of three life cycle stages of Gymnodinium catenatum[END_REF][START_REF] Persson | Grazing on toxic Alexandrium fundyense resting cysts and vegetative cells by the eastern oyster (Crassostrea virginica)[END_REF] and sometimes have been reported to contain six [START_REF] Oshima | Toxin composition of resting cysts of Alexandrium tamarense (Dinophyceae)[END_REF] to ten folds (Yentsch and Mague, 1979) more toxin than vegetative cells. Dinoflagellate cysts are one of the food sources of bivalves [START_REF] Tsujino | Fate of resting cysts of Alexandrium spp. ingested by Perinereis nuntia (Polychaeta) and Theola fragilis (Mollusca)[END_REF][START_REF] Persson | Grazing on toxic Alexandrium fundyense resting cysts and vegetative cells by the eastern oyster (Crassostrea virginica)[END_REF].

Many studies have suggested that consumption of cysts may be the direct cause of toxicity in bivalves, especially during the winter months [START_REF] Shumway | Paralytic shellfish poisoning in Maine: monitoring a monster[END_REF][START_REF] Schwinghamer | Resuspended hypnozygotes of Alexandrium fundyense associated with winter occurrence of PSP in inshore Newfoundland waters[END_REF][START_REF] Anderson | Diversity of harmful algal blooms in coastal waters[END_REF][START_REF] Bravo | PSP toxin composition of three life cycle stages of Gymnodinium catenatum[END_REF].

Daya Bay is a site of recurrent PSP episodes [START_REF] Anderson | Paralytic shellfish poisoning in Southern China[END_REF][START_REF] Lin | Paralytic shellfish poison in contaminated shellfish along coast of China[END_REF] with the highest PSP toxin levels among the Chinese coastal areas [START_REF] Lin | Paralytic shellfish poison in contaminated shellfish along coast of China[END_REF]Jiang et al., 2000a). Human mortalities and hospitalizations have occurred from time to time in nearby areas following consumption of toxic mussels. Five persons were poisoned due to consumption of the contaminated shellfish in 1989 [START_REF] Jian | Analysis of seafood poison caused by clam Pinna pectinara[END_REF], and three persons died after shellfish consumption in 1993 [START_REF] Lin | Paralytic shellfish poison in contaminated shellfish along coast of China[END_REF]. Bivalves collected from this sea area had PSP toxin concentrations exceeding the regulatory limit of 800 µg STX equiv./kg, and a maximum concentration of 10 000 µg STX equiv./kg was reported (Jiang et al., 2000a;Yang et al., 2005). The highest contents of PSP toxins were detected during the winter months (Jiang et al., 2000a). Despite the long-known occurrence of PSP toxins, PSP causative species, such as Alexandrium spp. and Gymnodinium catenatum, were seldom recorded in phytoplankton survey (Zhou et al., 1998;[START_REF] Liu | Ecological response of phytoplankton to the operation of Daya Bay nuclear power station[END_REF]. However, abundant Alexandrium cyst were recorded in surface sediments from this area, and it was suggested that high PSP toxin levels in bivalves during the winter months were probably due to ingestion of cysts of Alexandrium [START_REF] Wang | Dinoflagellate cyst records in recent sediments from Daya Bay, South China Sea[END_REF]. Therefore, we set up sediment traps at two stations of Daya Bay, bred shellfish synchronously at the same areas, and conducted phytoplankton surveys.

For phytoplankton community and its relationships with environmental parameters, see [START_REF] Wang | C. nobilis St.2 C. nobilis St.1 P. viridis St.2 P. viridis Fig. 4 Concentrations of PSP toxins in shellfish PSP concentration (µg STXequiv./kg)[END_REF]. In this study, we analyzed the annual data of Alexandrium vegetative cell and its cyst, and the PSP concentrations in shellfish. The purpose is to investigate the seasonal variation in the population size of Alexandrium (cell density and cyst flux) and their relationship with PSP levels in shellfish.

Materials and Methods

Site description

Daya Bay is located in the southeast part of the South China Sea (22°30´-22°50´N, 114°30´-114°50´E). It is a semi-enclosed shallow embayment with depth ranging from 6 m to 15 m. It covers an area of 650 km 2 and is separated into several small sub-basins. The bay has a mild and wet subtropical climate with an annual mean air temperature of 22 °C. The coldest months are January and February, with a monthly mean air temperature of about 15 °C, and the hottest months are July and August, with a monthly mean air temperature around 28 °C. Salinity usually lies between 22 and 33 with little fluctuation except during the typhoon season from July to September. The Daya Bay Nuclear Power Station (DNPS), the first nuclear power station in China, has been operating since February 1994, and it discharges cooling water at the rate of 2.9×10 7 m 3 /year [START_REF] Liu | Ecological response of phytoplankton to the operation of Daya Bay nuclear power station[END_REF].

Sampling stations (Fig. 1) were located in two cultural areas of the bay. St. 1 was located at 22°33′25.7″N, 114°30′54.1″E, where Pteria spp. were bred in suspended cages. St. 2 was at a fish cage area (22°33′51.7″N, 114°31′20.2″E), which was closer to the shore and close to the residential area.

Nutrients and hydrographic parameters

Temperature (T), Salinity (S) and dissolved oxygen (DO) were recorded in situ with an YSI meter (YSI 85, YSI Incorporated, USA) once every three days. Transparency and nutrients were measured every two weeks. Transparency was measured with a Secchi disk.

M A N U S C R I P T A C C E P T E D ACCEPTED MANUSCRIPT

5

Water samples for nutrient determination were collected in the subsurface water column (0.5 m), immediately filtered through glass fibre filters (Whatman GF/F, porosity=0.7 µm), and placed in a freezer. Nutrients, including dissolved inorganic nitrogen (DIN, the sum of ammonium, nitrite and nitrate), dissolved inorganic phosphorus (DIP, orthophosphate) and dissolved silicon (DSi, silicate), were analysed following standard methods of State Oceanic China (SOC, 1991) within 24 hours.

Phytoplankton sampling and observation

Water samples of 1000 mL were collected in the subsurface water column once every three days for phytoplankton observation and fixed immediately with neutralized formalin to a final concentration of 4%. The fixed water samples were finally concentrated to 20 mL by sedimentation. Phytoplankton species were counted from aliquots of 0.5-1.0 mL sub-samples using a microscope (Leica DMIRB) at magnifications of 100x to 600x. The phytoplankton abundance was presented as cell numbers per millilitre (cells/mL).

The thecal plate morphology of Alexandrium cells was examined using phase contrast and UV epifluorescence microscopy after calcofluor staining [START_REF] Fritz | A rapid simple technique utilizing Calcofluor White M2R for the visualization of dinoflagellate thecal plates[END_REF] under a Leica DMIRB microscope. The thecal plate tabulation and the shapes of plates and apical pore complex proved that the dominant Alexandrium species was A. tamarense.

Sediment collection and cyst observation

The sediment trap was set to collect settling materials from March 24, 2005 to June 10, 2006. The trap consisted of a cylindrical PVC collector (height 35cm, diameter 7cm, height/diameter ratio 5), flexible tube holder, subsurface buoy, surface buoy marker, and anchor. The trap was moored at 1.0 m from the sea bottom (depth at the deployment location was about 6 m).

Trap samples were collected every two weeks. The settled material was suspended in 2000 mL seawater, and the suspension was divided into two 1000 mL aliquots, one of which was fixed with 4% buffered formalin and subsequently concentrated to 50 mL by sedimentation.

Sediment samples were gently sonicated for 30 seconds. The sonicated material was then

M A N U S C R I P T A C C E P T E D ACCEPTED MANUSCRIPT 6
sieved through 125 µm and 20 µm metallic screens to remove larger particles and detritus, and the slurry remaining on the 20 µm screen was washed into a beaker and collected into a plastic tube to a final sample volume of 10 mL with filtered seawater. For observation, 0.1 to 0.5 mL aliquots of sample were placed on a 1 mL counting chamber and diluted with appropriate distilled water.

Observation was under an inverted light microscope (Leica DMIRB). Only living cysts that had not germinated were counted. At least three observations were conducted for each sample until 200 dinoflagellate cysts were observed. Mean daily cyst flux (cysts/cm 2 d) was calculated. Four seasons during the survey were defined as: spring, March to May; summer, June to August; autumn, September to November; and winter, December to next February.

Shellfish breeding and PSP analysis 2.5.1 Shellfish breeding and sampling

At the beginning of the survey on March 24, 2005, 600 scallops (Chlamys nobilis) were bought from the local shellfish farm. Half of the scallops were placed in lantern nets and hung from long lines 3 m below the surface in each of the two stations. Green mussels (Perna viridis) were collected from fishing crossrails and ropes and shellfish cages. About 10 scallops (mean shell length of 9.48±0.44cm) and 20 green mussels (mean shell length of 9.19±0.95cm) were collected in each station for PSP toxin determination every two weeks. The shells were dissected immediately after being washed with a brush and rinsed with DI water. Whole soft tissues were removed from the shells and washed with DI water gently. Digestive glands were carefully removed from the rest of tissues. Both the digestive glands and other tissues were weighed and placed in plastic bags separately and stored in a freezer. During the transportation to the laboratory (within 4 h), the tissue samples were stored at -20 °C.

Mouse bioassay

As the toxicities of most samples were below detection level, the digestive glands were treated and analysed first in order to screen out any contaminated samples. If the digestive glands were toxic to test mice, the remaining tissues of the same sample then treated and assayed. Sample treatment and mouse bioassay were performed according to the standard

M A N U S C R I P T A C C E P T E D ACCEPTED MANUSCRIPT
AOAC procedure (Association of Official Analytical Chemists, [START_REF] Aoac | Paralytic shellfish poison. Biological method. Final action[END_REF] with the exception that samples sizes were smaller (about 20 g digestive gland homogenate, equal volume of 0.1N HCl and digestive gland homogenate). Mouse bioassays were conducted using ICR strains, 19-21 g male mice. The mice (3-6 mice per extract) were observed for 1 h, and the mean survival time was used to calculate the toxicity. When the extracts were too toxic, it was necessary to dilute the shellfish extract until the survival time was between 5 and 7 min. Bioassay results were calculated using a computer-based version of Sommer's table and correction table for mouse weight [START_REF] Sommer | Paralytic shellfish poisoning[END_REF]. The mouse bioassay was standardized using pure saxitoxin purchased from the National Research Council of Canada, Institute for Marine Biosciences (Halifax, Canada). The toxicity of the sample equals to the sum of toxicities of the digestive glands and the other tissues per kg total tissue (µg STX equiv./kg), and the toxicity of the digestive gland was expressed as µg STX equiv. per kg digestive gland.

HPLC analyses

Four digestive gland samples with high toxicity in mouse bioassay were selected for HPLC analysis (Table 1). Each sample was divided into two sub-samples. One sub-sample was extracted in 0.1 N HCl according to the AOAC extraction procedure as described in 2.5.2, and another was extracted in 1% (v/v) acetic acid solution according to [START_REF] Lawrence | Quantitative determination of paralytic shellfish poisoning toxins in shellfish using prechromatographic oxidation and liquid chromatography with fluorescence detection: interlaboratory study[END_REF].

Toxin contents and profiles were determined using the post-column oxidation method [START_REF] Oshima | Post-column derivatization HPLC methods for paralytic shellfish poisons[END_REF] modified by [START_REF] Anderson | Paralytic shellfish poisoning in Southern China[END_REF]. The HPLC system used was an Agilent Series 1100, fitted with an autosampler and fluorescence detector (Agilent, USA). Three separate isocratic elutions were employed to separate different sets of PSP toxins at a flow rate of 0.8 mL/min: (1) 2 mM tetrabutyl ammonium phosphate solution adjusted to pH 6.0 with acetic acid for C toxins; (2) 2 mM 1-heptanesulphonic acid in 10 mM ammonium phosphate buffer (pH 7.1) for GTX and dcGTX group; and (3) 2 mM 1-heptanesulphonic acid in 30 mM ammonium phosphate buffer (pH 7.1): acetonitrile (100:5) for the STX group.

Toxin standards, GTX1-5, neoSTX, STX, dcSTX, dcGTX2/3 and C1, C2, were purchased from the National Research Council of Canada, Institute for Marine Biosciences (Halifax,

M A N U S C R I P T A C C E P T E D ACCEPTED MANUSCRIPT 8
Canada). The standards solutions were diluted with 0.03 N acetic acid as required. PSP toxin profiles were calculated from the percentages of individual toxin concentrations of the total PSP toxin concentrations for each sample (mol %). The relative toxicities (µg STX equiv./kg) were calculated based on the specific toxicities given by [START_REF] Oshima | Post-column derivatization HPLC methods for paralytic shellfish poisons[END_REF].

Results

Environmental conditions

Water temperature ranged from 14.0 to 32.8 °C, with the lowest recorded from December to early March and the highest from July to November. Salinity was relatively stable with an annual mean value of 29.3, except for the rainy season from April to May and from July to September.

Nutrient concentrations showed similar seasonal changes at the two stations.

Concentrations of DIN ranged from 2.04 µmol/L to 14.94 µmol/L, and showed an annual cycle characterized by higher values during spring and summer and lower values during late autumn and winter. Concentrations of DIP remained consistently low, and ranged from 0.044 µmol/L to 1.67 µmol/L. DSi concentrations were remarkably high during the flood season between July and September, and low in winter and the early spring dry season. Annual mean values in DIN and DIP showed no significant differences between the two stations; however, DSi level was obviously higher at St. 1 than St. 2, with mean concentrations of 17.8 µmol/L and 12.2 µmol/L, respectively.

Abundance of A. tamarense vegetative cells

The vegetative cells of A. tamarense occurred sporadically in the water column and showed a regular seasonal cycle. Vegetative cells only occurred during spring (March to May) and winter (November to February) (Fig. 2). The abundance during spring was low, ranging from 0.2 to 1.4 cells/mL. The vegetative cells were not detected during summer and autumn (Fig. 2) when water temperature exceeded 25 °C. Cell numbers increased at the end of November with decreasing water temperature and peaked in January and February, when water temperatures were around 20 °C. Cell numbers were markedly higher in St. 1 than in St. The phytoplankton assemblages were dominated by diatoms, which constituted 93.2% of total phytoplankton population. Dinoflagellates occurred in low numbers with a mean abundance of 9.4 cells/mL, and represented only 1.2% of total abundance. The abundance of total phytoplankton was 3 920 cells/mL when the maximum cell number of A. tamarense occurred. The most dominant species was Skeletonema costatum at that time, with a cell density of 3 230 cells/mL and proportion of 82.5%. A. tamarense accounted for 98.3% of dinoflagellate, but only 15.3% of total phytoplankton.

Cyst flux of A. tamarense

Cysts of A. tamarense occurred frequently in the sediment traps, but in low numbers (mostly <5 cysts/cm 2 d). Cysts appeared to have a seasonal cycle similar to that of the vegetative population and occurred more abundantly during spring and winter (Fig. 2

PSP toxins in shellfish

The extracts of shellfish tissues in the present study killed mice with typical symptoms associated with PSP toxins. Seasonal variations in toxin concentration are illustrated in Fig. 4.

The PSP toxins in the two stations were generally below the regulatory limit, except for the winter months. The concentrations of PSP toxins were lower in spring and early summer, and PSP toxins were not detected between August and October. Toxin concentrations increased significantly in January, and a maximum level of 14 015 µg STX equiv./kg was recorded in P.

M A N U S C R I P T A C C E P T E D ACCEPTED MANUSCRIPT

10 viridis samples collected from St. 1 on January 3, 2006 (Fig. 4). The majority of toxins were detected in digestive glands, with the maximum of 66 227 µg STX equiv./kg in digestive glands from C. nobilis collected at St. 1 on January 3, 2006 (Fig. 5). Toxins in other tissues were very low to undetectable except for five samples collected in January 2006, with a maximum level of 392 µg STX equiv./kg. The results showed that the hepatopancreatic tissues from both P. viridis and C. nobilis were unsafe for human consumption during the winter months, while the tail muscle would be safe.

Toxin levels in digestive glands from C. nobilis (mean value of 3 373 µg STX equiv./kg) were significantly higher than those from P. viridis (mean value of 1 531 µg STX equiv./kg).

However, the contribution of digestive gland to total tissues is lower in C. nobilis than in P. viridis. Therefore, toxin concentrations in total tissues of the two shellfish were similar, with mean values of 399 and 394 µg STX equiv./kg in C. nobilis and P. viridis, respectively.

The sharp increase in concentrations of PSP toxins in January was coincident with the occurrence of Alexandrium population (both vegetative cells and cysts), with peak concentrations or abundances between January and March. PSP concentrations were clearly higher in St. 1 than in St. 2, and the averages in digestive glands and total tissues were 3 796 and 632 µg STX equiv./kg in St. 1 and 1 107 and 161 µg STX equiv./kg in St. 2, respectively.

PSP toxin profiles

Fig. 6 illustrates the toxin profiles in four digestive gland samples treated by HCl and acetic acid, respectively. Of the 12 components analyzed in this study, GTX5 and dcGTX2 were not detected in any of the samples, and only trace amounts of decarbamoyl toxins were detected with a mean proportion of 2.2%. The PSP toxin profiles in HCl extracts were rich in carbamate toxins (mean 63.7% of the total) and dominated by GTX2 (mean 35.1%), GTX3 (mean 26.2%) and GTX4 (mean 15.7%). C toxins accounted for a medium amount of the total (around 0-12% for C1, 1-7% for C2). In addition to these components, a trace amount of decarbamoyl toxins (mean 3.3%) was detected. In contrast, in acetic acid extracts, large amounts of C toxins were detected instead, and C1 (around 38-68% of the total, mean 53.6%) was the most abundant. On the other hand, concentrations of GTX toxins dropped

M A N U S C R I P T A C C E P T E D ACCEPTED MANUSCRIPT

11 significantly and accounted for 4-31% of the total, with an average of 17.8%. The relative concentrations of STX toxins (including STX, dcSTX and neoSTX) in acetic acid extracts (mean 22.1%) were similar to those in HCl extracts (mean 18.4%); however, percentages of STX increased from 6.7% in HCl extracts to 13.9% in acetic acid extracts on average. Though samples collected from St. 1 on 3 January 2006 were most toxic during study period (Fig. 4,5), the toxin profiles (sample 1 and 1') showed less toxic GTX2 and C1 (Fig. 6). Other less toxic samples (samples 2-4, and 2'-4') had higher proportions of more toxic components such as STX, neoSTX and GTX4. However, toxin concentrations on a molar basis (µmol/kg) in sample 1 and 1' were 5-8-fold greater than those in other samples (Table 1).

Toxin concentrations on a molar basis (µmol/kg) were comparable between any two parallel samples treated by HCl or acetic acid (Table 1). The toxicities in HCl extracts approximately coincided with those analyzed by mouse assay. However, samples treated by acetic acid showed only one-third to two-thirds of those treated by HCl, especially in samples with rich contents of C1 toxin (Table . 1, Fig. 6).

Discussion

High abundance of A. tamarense vegetative cells was observed in this study, with a maximum number of 603 cells/mL. In previous phytoplankton studies, vegetative cells of Alexandrium were seldom observed in the water column during seasonal routine observation due to the long interval of sampling [START_REF] Liu | Ecological response of phytoplankton to the operation of Daya Bay nuclear power station[END_REF]. However, peak abundance of A. tamarense was captured in this survey by highly frequent sampling (once every three days).

Alexandrium tamarense showed a high dispersal of temperature/cell density couples (Fig. 7). It never occurred at temperatures greater than 30 °C, and peak abundances occurred when temperature lies between 16 and 20 °C. A. tamarense is a stenohaline alga (ca. 15-25 °C) with optimal growth at 17-22 °C (Yan et al., 2002). The blooms of Alexandrium usually occurred in temperatures between 13 and 18 °C [START_REF] Giacobbe M Goliva | Environmental factors and seasonal occurrence of the dinoflagellate Alexandrium minutum, a PSP potential producer, in a Mediterranean lagoon[END_REF][START_REF] Gracéc | Relationship between vegetative cells and cyst production during Alexandrium minutum bloom in Arenys de Mar harbour (NW Mediterranean)[END_REF]. After the operation of DNPS, the annual mean water temperature increased by 0.4-1.1 °C (Tang et al.,

M A N U S C R I P T A C C E P T E D ACCEPTED MANUSCRIPT 12 2003
), and the variation in temperature was more significant in winter months, increasing from 16.04 °C to 18.03 °C [START_REF] Wang | Ecological environment changes in Daya Bay, China, from 1982 to 2004[END_REF], which seem to favor the growth of Alexandrium. Meanwhile during this period, nutrient loadings had increased significantly in the bay [START_REF] Wang | Ecological environment changes in Daya Bay, China, from 1982 to 2004[END_REF], facilitating the rapid growth of phytoplankton, especially the small diatoms with high growth rates [START_REF] Liu | Ecological response of phytoplankton to the operation of Daya Bay nuclear power station[END_REF][START_REF] Wang | C. nobilis St.2 C. nobilis St.1 P. viridis St.2 P. viridis Fig. 4 Concentrations of PSP toxins in shellfish PSP concentration (µg STXequiv./kg)[END_REF]. The phytoplankton abundances peaked in spring and summer during the early 1990s (Zhou et al., 1998), but frequent winter peaks have been observed since the late 1990s [START_REF] Liu | Ecological response of phytoplankton to the operation of Daya Bay nuclear power station[END_REF][START_REF] Wang | C. nobilis St.2 C. nobilis St.1 P. viridis St.2 P. viridis Fig. 4 Concentrations of PSP toxins in shellfish PSP concentration (µg STXequiv./kg)[END_REF]. Generally, Daya Bay is characterized by high levels and rapid compensation of nutrients, however, temporary shortage of nutrients occurs when the diatom bloom exhausts the nutrients, particularly during the dry low-nutrient winter season [START_REF] Wang | C. nobilis St.2 C. nobilis St.1 P. viridis St.2 P. viridis Fig. 4 Concentrations of PSP toxins in shellfish PSP concentration (µg STXequiv./kg)[END_REF].

Dinoflagellates such as Alexandrium are more competitive in nutrient depletion conditions due to its higher nutrient affinities and capability to utilize organic nutrients [START_REF] Collos | Contribution of several nitrogen sources to growth of Alexandrium catenella during blooms in Thau lagoon, southern France[END_REF]. As a result of higher winter temperatures and increased nutrient loading, Alexandrium has occurred more frequently and abundantly during winter months, which contributes to the high PSP concentrations in shellfish.

Cyst fluxes were recorded during summer and autumn (June to October), when no vegetative cells of A. tamarense were observed in the water column. The absence of vegetative cells in the subsurface water column during the observation does not necessarily indicate their absence in the entire water column. More likely, the water sample collection did not catch A. tamarense cell patches due to random sampling. In addition, this period is also the typhoon season in South China Sea. Strong storms may cause a high resuspension rate, which could result in redeposition of bottom cysts into sediment traps.

Similar to the total phytoplankton abundance, cell density and cyst flux of A. tamarense were clearly higher in St. 1, located in a shellfishery area, than those in St. 2, located in a fish cage area. This resulted in higher PSP levels in shellfish collected from St. 1. The low primary production in the fishery area was observed in another study in this area as well [START_REF] Huang | Impact of cage fish farming on water environment in Daya Bay[END_REF]. Meanwhile, higher concentrations of Alexandrium cyst were recorded in surface sediments from the shellfishery area in the same sea area [START_REF] Wang | Dinoflagellate cyst records in recent sediments from Daya Bay, South China Sea[END_REF]. This

M A N U S C R I P T A C C E P T E D ACCEPTED MANUSCRIPT

13 phenomenon may be interpreted as compensatory growth of phytoplankton against predatory pressure by shellfish.

Daya Bay has been reported to have the highest PSP concentrations among the Chinese coastal areas [START_REF] Lin | Paralytic shellfish poison in contaminated shellfish along coast of China[END_REF]Yang et al., 2005). Jiang et al. (2000a) found that the highest concentration of PSP toxins occurred in January during their survey conducted between 1997 and 1999. However, Alexandrium was seldom observed in previous phytoplankton surveys [START_REF] Liu | Ecological response of phytoplankton to the operation of Daya Bay nuclear power station[END_REF]. Our results showed that high cell numbers and cyst fluxes of Alexandrium coincided with high PSP levels in shellfish. In addition, content of PSP toxins showed a strong positive relationship with the accumulative abundances of vegetative cells and cysts [ln(PSP) = 0.41 × ln(Cells) + 2.34, r = 0.647, n = 27, p = 0.002; ln(PSP) = 0.37 × Cysts + 5.22, r = 0.373, n = 27, p = 0.04]. These results suggest that vegetative cells and cysts of Alexandrium influenced significantly the PSP levels, and could have contributed to high PSP levels in shellfish during winter.

However, toxin levels were not always consistent with concentrations of vegetative cells and cysts. The inconsistence of PSP contamination in shellfish and concentration of Alexandrium cells and cysts might be explained by the variability of Alexandrium toxicity, which depends on environmental conditions, among species and strains [START_REF] Anderson | Toxin composition variations in one isolate of the dinoflagellate Alexandrium fundyense[END_REF].

Toxicities in Alexandrium vegetative cells and cysts seem to be species and strain specific.

The average toxicity of A. tamarense vegetative cells is approximately 16 pg STX equiv./cell [START_REF] Persson | Grazing on toxic Alexandrium fundyense resting cysts and vegetative cells by the eastern oyster (Crassostrea virginica)[END_REF]. [START_REF] Oshima | Toxin composition of resting cysts of Alexandrium tamarense (Dinophyceae)[END_REF] reported as much as 269 pg STX equiv./cyst in A.

tamarense, and Bricelj and Shumway (1998) reported 325 pg STX equiv./cell of an Alexandrium sp. [START_REF] Beppu | Occurrence of PSP-producing dinoflagellate Alexadnrium tamiyavanichii in Bingo-Nada, the central coastal water of Seto Inland Sea, Hiroshima Prefecture, Japan[END_REF] measured the toxicities of six trains of Alexandrium from the coastal water of Hiroshima Prefecture, Japan, and found that variation in the toxin level was varied about 30 fold among strains (from 3.7 to 111.5×10 -6 MU/cell), or 10 fold even between A. tamarense strains isolated from the same sea area in the same month of different years.

The toxin profiles of HCl treated samples were similar to those reported by Jiang et al. (2000b) in the same sea area, in which GTX toxins were found to be the main component. [START_REF] Lassus | Patterns of experimental contamination by Protogonyaulax tamarensis in some French commercial shellfish[END_REF][START_REF] Ichimi | Non-selective retention of PSP toxins by the mussel Mytilus galloprovincialis fed with the toxic dinoflagellate Alexandrium tamarense[END_REF][START_REF] Abouabdellah | Paralytic shellfish poisoning toxin profile of mussels Perna perna from southern Atlantic coasts of Morocco[END_REF]. Toxin profiles of acetic acid extracts showed good similarity with those of Alexandrium strains isolated from the nearby sea areas (Jiang et al., 2000b;[START_REF] Wang | Paralytic shellfish toxin profiles and toxin variability of the genus Alexandrium (Dinophyceae) isolated from the Southeast China Sea[END_REF], which were predominated by C1/C2 toxins and had only trace amounts of STX toxins. The results suggested PSP toxins in filter-shellfish detected in this study were possibly produced by a local strain. It is well known that the AOAC extraction procedure used in the sample preparation converts the sulphocarbamoyl toxins (C1-4, B1, B2) into corresponding carbamates [START_REF] Laycock | Some in vitro chemical interconversions of paralytic shellfish poisoning (PSP) toxins useful in the preparation of analytical standards[END_REF][START_REF] Anderson | Paralytic shellfish poisoning in Southern China[END_REF], i.e., C3,4 to GTX1,4 and C1,2 to GTX2,3 [START_REF] Turrell | Determination of paralytic shellfish poisoning (PSP) toxins in UK shellfish[END_REF]. Our results also showed evident toxin conversion through the HCl procedure, as displayed by the remarkable increase of GTX2, 3 and sharp decrease of C1, and meanwhile a comparatively stable overall toxin concentrations on molar basis (mol/kg).

The carbamates are considerably more toxic than the corresponding sulphocarbamoyls, and, consequently, changes in toxin profile after HCl treatment will increase the toxicity of the shellfish extract [START_REF] Kao | Paralytic shellfish poisons[END_REF]. In our study, toxicities of HCl extracts were 1.5-3.5-fold higher than those of corresponding acetic acid extracts. Despite the increase toxicity through HCl procedure, we suggest using HCl extracts in the mouse bioassay. This procedure better protects human health by considering the potential conversion of C toxins into more poisonous GTX toxins in human body.

Conclusion

Our one-year observation found that high PSP toxin levels in shellfish coincided with peak abundances of cell and cyst of A. tamarense during winter months, though the toxin levels were generally below the regulatory limit for most seasons of the year. The significant, positive relationship between toxin level, and vegetative cell and cyst abundance reveals possible toxin source from Alexandrium thriving during winter months. More specifically, the majority of the toxins were accumulated in the digestive glands. Zhou, P., Lin, Y., Wang, Z., 1998. A statistical analysis on phytoplankton community features in waters of Daya Bay. Tropic Oceanol. 17 (3), 57-64 (in Chinese, with English abstract). 2 was at a fish cage area close to a residential area. 2 was at a fish cage area close to a residential area.

M A N U S C R I P T A C C E P T E D

  the maximum cell number of 603 cells/mL was observed in St. 1 on February 19, 2006. Maximum number coincided with low water temperature and low nutrient concentrations during the winter months.

  , Fig. 3). High cyst fluxes were observed approximately two weeks to one month after the vegetative cell peaks. For example at St. 1, there was a significant increase in cyst flux in January 2006 just following vegetative cell peaks in December and January, and the maximum flux of 42.6 cysts/cm 2 d was observed on February 11-26, 2006, right after the maximum number of vegetative cells. Meanwhile, a strong positive correlation existed between cyst flux and the cumulative number of vegetative cell (Cysts = 6.64 × 10 -5 × Cells + 0.77, r= 0.995, n = 27, p<0.0001).

  dominant in contaminated shellfish as determined by the AOAC HCl extraction method in other geographic regions

  ., Zhou, M. J., Qian, P. Y., 2002. Study on the combined effects of temperature, salinity and irradiance on the growth of dinoflagllate Alexandrium tamarense. Acta Oceanol. Sin. 24(2), 114-120 (in Chinese, with English abstract). Yang, M., Lin, Q., Lu, X., Cai, W., 2005. The paralytic shellfish poison content in the oysters in important maricultural waters along Guangdong Coast. Mar. Environ. Sci. 24(1), 48-50 (in Chinese, with English abstract). Yentsch, C.M., Mague, F.C., 1979. Motile cells and cysts: two probable mechanisms of intoxication of shellfish in New England waters. In: Taylor, D.L., Seliger, H.H. (Eds.), Toxic Dinoflagellate Blooms. Elsevier/North-Holland, pp. 127-130.

Fig. 1

 1 Figure captions

Fig. 2

 2 Fig. 2 Seasonal changes in cell density of Alexandrium tamarense

Fig. 7

 7 Fig. 7 Relationship between cell density of Alexandrium tamarense and water temperature.

Fig. 1

 1 Fig. 1 Sampling stations in Daya Bay, South China Sea. Also shown is the location of the

Tables

  Table 1 PSP toxin contents in digestive gland samples by HPLC analysis and mouse bioassay using the AOAC HCl procedure and acetic acid extraction procedure, respectively P. viridis samples from St. 1 on January 3, 2006, 2 and 2': P. viridis samples from St. 1 on January 22, 2006, 3 and 3': P. viridis samples from St. 1 on February 26, 2006, 4 and 4': C. nobilis samples from St. 1 on March 16, 2006. Samples 1-4 were treated by HCl, samples 1'-4' were treated by acetic acid. "-" indicates without bioassay data.

		1	1'	2	2'	3	3'	4	4'
	Toxin concentration by
	HPLC	191.5	173.4	18.6	15.3	23.5	18.6	22.8	24.4
	(µmol/kg)
	Toxicity by HPLC
	analysis	41 584 11 993 4 477 1 842 5 377 3 424 6 135 2 832
	(µg STX equiv./kg)
	Toxicity by mouse
	bioassay	51 565	-	6 636	-	6 780	-	5 551	-
	(µg STX equiv./kg)
	1 and 1':

Acknowledgements

This research was funded by the National Natural Science Foundation of China (41076093, 40306020), and the Fundamental Research Funds for the Central Universities. We are very grateful to Miss Na Wang of Xiamen University for HLPC analysis.


Benoit Da Mota
email: benoit.damota@inria.fr

Vincent Frouin
email: vincent.frouin@cea.fr

Edouard Duchesnay
email: duchesnay@gmail.com

Soizic Laguitton
email: soizic.laguitton@gmail.com

Gaël Varoquaux
email: gael.varoquaux@inria.fr

Jean-Baptiste Poline
email: jbpoline@gmail.com

Bertrand Thirion
email: bertrand.thirion@inria.fr

Da Benoit

Parietal Mota

Team

Jean-Bapiste Poline

A fast computational framework for genome-wide association studies with neuroimaging data

Keywords: Bio-statistics, Neuroimaging, Genetics, Genome-Wide Brain-Wide Analysis, Mass Univariate Linear Model, Permutation Tests, Spatial Model, Cluster-Level Inference

Introduction

The integration of genetics information with neuroimaging data promises to significantly improve our understanding of both normal and pathological variability of brain organization. It should lead to the development of biomarkers and in the future personalized medicine. Among Figure 1. Sketch of the cluster-level analysis. Colors of the boxes are references to tasks of our framework described in Figure 2 (MULM: Mass Univariate Linear Model ).

other important steps, this endeavor requires the development of adapted statistical methods to extract significant correlations between the highly heterogeneous variables provided by genotyping and brain imaging, and the development of the software components that will permit large computation to be done.

In current settings, neuroimaging-genetic datasets consist of a set of i) genotyping measurements on genetic variables, such as Single Nucleotide Polymorphisms (SNPs) that represent a large amount of the genetic between-subject variability, on the one hand, and ii) quantitative level at given locations (voxels) in three-dimensional images, that represent either the amount of functional activation in response to a certain task or an anatomical feature (e.g. the density of grey matter in this brain region). The standard approach for voxelwise Genome-Wide Association Studies (vGWAS) is the Mass Univariate Linear Model (MULM) [START_REF] Stein | Voxelwise genome-wide association study (vGWAS)[END_REF], that considers each (SNP, voxel) pair independently and tests the significance of the correlation between these traits. With 50k voxels and 500k SNP, the number of comparisons reaches to 25 billions, thus controling the Type 1 error rate at p < .05 with Bonferroni family-wise error rate (FWER) correction implies a selecting only p-value smaller than 2.10 -12 . However, genetic markers are not independent, such that the genotype of two close SNP on the same chromosome tend to be highly correlated, due to the cross over phenomenom during cell meiosis (this is called linkage desiquilibrium or LD). It implies that Bonferroni correction yields conservative thresholds, at the expense of statistical power. This approach is therefore weakly sensitive, as it detects only extreme peaks in the statistics and fails to uncover smaller, but spatially extended, effects. Analytical corrections have been proposed to take into account thee correlations between these variables, but they yield only small improvement, and their theoretical validity needs to be further assessed [START_REF] Gao | Avoiding the high Bonferroni penalty in genome-wide association studies[END_REF]. In the brain imaging domain, cluster-level analysis techniques have been proposed [START_REF] Hayasaka | Validating cluster size inference: random field and permutation methods[END_REF], where the statistical test deals with the size of supra-threshold regions, for a predefined detection threshold (see Figure 1). In the absence of accurate statistical model of the largest cluster size under the null hypothesis, these approaches require permutations to control the significance of the decision statistic. Permutations also automatically adapt the threshold to the amount of correlation among genetics variables.

To assess the statistical significance with a sufficient accuracy, up to 10 4 permutations are needed. Traditional computational architectures that rely on popular analysis softwares (Plink or SPM) cannot manage this load in a reasonable amount of time. The size of our problem makes the computational load a primary concern and many parameters should be taken into account to design efficient and scalable parallel procedures. Working in a distributed context is necessary to deal with the memory and computational loads, and yields specific optimization strategies. For instance, with permutation tests the most natural way of spliting the problem consists in distributing the computations according to permutations. But this causes inefficient access to data, because each sub-problem needs all the data. With such natural data parallel application, the main task is to choose how to split the problem into smaller sub-problems to minimize computation and communication overhead. For the first time, we propose an efficient framework that can manage cluster-based inference in a vGWAS.

In Section 2, we describe our framework to distribute efficiently the computation on large infrastructures, then present the optimization of the sequential algorithm. Experimental results on simulated and real data are presented in Section 3.

Methods : the computational framework

The mass-univariate statistical analysis of neuroimaging genetics is clearly an embarrassingly parallel problem, nevertheless this can be easily split into smaller tasks. A good computational framework has to rely on an adapted workflow and each sub-task has to be optimized for the sake of efficiency. Although these two steps must be addressed jointly in practical settings, to simplify the presentation we first describe the workflow and then the optimization of the algorithms.

@ COMPSTAT 2012

The distributed algorithm

The MapReduce framework [START_REF] Chu | Mapreduce for machine learning on multicore[END_REF][START_REF] Dean | MapReduce: simplified data processing on large clusters[END_REF] seems the most natural approach to handle this problem and can easily harnest large grids. The Map step yields statistical scores between each (SNP, voxel) pair and the reduce step consists in collecting all results to compute statistic distribution and corrected p-values. Scores are p-values obtained with an Ordinary Least Square (OLS) regression. The key point is to create subtasks in a way that minimises inputs/outputs (I/O); in particular, requiring all the data for each subtask is a waste of ressources. By essence, permutations imply computations on the same data after shuffling. So the permutation procedure should be embedded in the inner loop, such that all permutations are done on the same node for a given dataset. The problem can be split in two other directions: genomic and/or brain data, where each one can have up to 10 6 variables. We choose to split in both dimensions for performance and memory reasons. As cluster-based inference requires all scores per SNP in all the brain, we introduce in the MapReduce framework a new task, the combine task, that combines several map results to do the cluster-based computation. The combine task is used to pre-compute statistic distributions and drastically reduces the amount of data transfered between the combine and reduce phase. Figure 2 gives an overview of our framework.

Optimization of the sequential algorithm

Algorithm 2.1 Fit the model Y = xβ + Zγ + ǫ for all x in X = [x 1 , .., x q ] and get a score for each pair (SNP, voxel) Require: The data Y, the X and Z regressor matrices if first regression then

Z w ← (Z T Z) -1/2 Z {whitening} Y norm ← Y ∆ 1 -1 with ∆ 1 = diag( Y i , i = 1 . . . p) {p number of voxels} X norm ← X∆ 2 -1 with ∆ 2 = diag( x i , i = 1 . . . q) {q number of SNPs} R Y |Z ← Y norm -Z w β1 with β1 = Z w T Y norm {residuals} R X|Z ← X norm -Z w β2 with β2 = Z w T X norm {residuals} cache ← Z w , R Y |Z , R X|Z else Z w , R Y |Z , R X|Z ← cache end if β ← R X|Z T R Y |Z γ ← Z w T R Y |Z {for Freedman and Lane approximation [16]} F-scores ∝ β2 1-β2 -Γ2 with Γ2 = r i=1 γ2 i {r = number of confounding variables} return β, F-scores
The map step is the most demanding in computation time (> 99% in our final implementation) and thus has to be optimized in priority. For one (SNP, voxel) pair, we want to fit the model y = xβ + Zγ + ǫ, where y is a vector of observations (i.e. values for a voxel), x a vector of number of minor alleles for a SNP, Z a matrix of confounding variables (age, sex, acquisition center, ...) and the intercept. We propose the Algorithm 2.1, that optimizes this step based on the following observations :

• To fit the model, the vector y is implied in only one product, so y should be a matrix such that several voxels are regressed during the same operation.

• The fit operation is dominated by a costly pseudo-inverse of the design matrix. If the regressors in the design matrix are orthonormal, the computation is simplified to a product, with a much lower cost.

• The effects of the confounding variables are first removed from y and x, then the regression is done on the residuals (R y|Z and R x|Z ). With this strategy, the fit of the last regression is a scalar product so that we can fit the regression of several voxels and SNPs in the same Matrix product.

• Some properties are insensitive to permutations and the results can be cached to speed up regressions on permuted data. For instance, the norm of a column does not change after a permutation on row, orthogonality is preserved too.

• Permutations can be done on the residuals. For this purpose, we use de method called permutation under the reduced model by Freedman and Lane [START_REF] Freedman | A nonstochastic interpretation of reported significance levels[END_REF], shown as the best possible approximation of the true model [START_REF] Anderson | Permutation tests for linear models[END_REF]. Further speed up can be achieved using the method proposed by Kennedy [START_REF] Kennedy | Randomization tests in econometrics[END_REF], however this approximation is not precise enough because we need very good accuracy far in the tail of the distribution.

The same level of detail cannot be handled depending on whether few genes or the whole genome were considered. In our setting, with the univariate model, keeping all the associations represents more than 2 petabytes in double precision (8 × 10 4 × 5.10 5 × 5.10 4 ). For this reason, we store only, in single precision, p-values lower than a threshold, called sparsity threshold. This reduction saves a large amount of time because of bandwidth and space economy. The aggregation of scores per SNP represents the other most significant fraction of the execution time of the mapper because norms of large matrices (number of voxels × number of SNPs) are involved. Normalizing the matrices greatly simplifies the calculation. We also take care of computational/hardware sources of optimization: CPU cache issues, data access pattern, I/O bottlenecks. For instance, if we profile the execution of the standard mass univariate linear model, we can observe that computing over phenotypes or explanatory variables one by one is inefficient. Matrix-based operations should thus be sued instead of vector-based operations. Our Python code uses the Numpy/Scipy scientific libraries, which rely on standard and optimized linear algebra libraries (Atlas or MKL) that are several order of magnitude faster than naive code.

Results

We present three types of results. As we aim to provide a fast whole brain whole genome exploratory tool, we evaluate the performances of our serial procedure and distributed framework. Then, we illustrate the interest of our approach on simulated data with known ground truth. Finally, we present our results on the IMAGEN study [START_REF] Schumann | The IMAGEN study: reinforcement-related behaviour in normal brain function and psychopathology[END_REF].

@

Performance evaluation of the procedure

To the best of our knowledge, there is only one voxel wise Brain-wide Genome-wide (BWGW) association study [START_REF] Stein | Voxelwise genome-wide association study (vGWAS)[END_REF] that reports computational performances. The authors used a modified version of the Plink software [START_REF] Purcell | PLINK: a tool set for whole-genome association and population-based linkage analyses[END_REF] to manage the size of the outputs. Plink is a popular whole genome association analysis toolset designed to be computationally efficient. In the domain of neuroscience, the most popular tool to do such study is SPM, but is far less efficient. Although SPM can be scripted, it is not designed for efficiency in studies with many external covariates, such as neuroimaging-genetics studies, so we do not report its performance.

As our approach is very different from Plink, we calculate the speed of a procedure in (SNP, voxel) associations per second with fixed number of samples, i.e. 740 to match the cohort size in the previous study [START_REF] Stein | Voxelwise genome-wide association study (vGWAS)[END_REF]. We use Plink (v1.06) and determine an optimistic time for a GWAS at around 2 seconds. Our experiments run on one core of a 2 × Intel(R) Xeon(R) CPU X5660 (6 cores) @ 2.8GHz with 24GB of memory. Our mapper runs with the academic version of the Entought Python Distribution (EPD 7.2-2-rh5 64 bits), with the MKL as linear algebra library with OpenMP parallelization disabled. The results are reported in Table 1. Compared to this study, we achieved the computations thousands times faster. In a more realistic comparison based on our target application, we evaluate the speedup to approximately 25. Note that Plink gives much more detailed results and a part of the speedup of our mapper comes from a reduction of the output. Indeed, the additional results are not required by our application.

To illustrate the scalability of our Map-Reduce procedure, we execute the whole framework on our cluster: 20 nodes; each one is a 2 × Intel(R) Xeon(R) CPU X5650 (6 cores) @ 2.67GHz with 48GB of memory, connected with Gigabit Ethernet LAN; all files were written on the NFS storage filesystem; the code was executed in the same Python environment as previously described; the workflow is described and submitted with the soma-workflow software [START_REF] Laguitton | Soma-workflow: a unified and simple interface to parallel computing resources[END_REF]. Somaworkflow framework enables i) to describe a set of independent tasks that are executed following an execution graph and ii) to execute the code by submitting the graph to classical queueing systems operating on the cluster. We report in Figure 3 the result of an execution with almost all the 240 cores available during all the run. The workflow is composed by 3,000 mappers, 300 combiners and 1 reducer tasks. The mappers represent 99.5% of the total of serial computation time, and the combiners 0.5%. We achieve a speedup of 227 comparing to the serial time. We can see in Figure 3 that after five hours, we use only half of the cores, but all the unused cores are available for other users. There are two easy ways to improve this speedup. First, if we can rely on a given number of cores, we can generate an optimal workflow. For instance, we can split to have 2,400 mappers, 240 combiners and 1 reducer with 240 cores. Second, we can split the problem into smaller pieces to decrease the time of the mappers. We do not explore further this possibilities, because performance is sufficient and we focus on experimental results.

Results on simulated data

We simulate functional Magnetic Resonance Images (fMRI) from real genetic data obtained from the Imagen database [START_REF] Schumann | The IMAGEN study: reinforcement-related behaviour in normal brain function and psychopathology[END_REF]. We use the number of minor alleles for each SNP and we assume an additive genetic model. Ten random SNPs produce an effect in a spherical brain region, centered at random positions in the standard space, then intersected with the support of grey matter using a mask computed for the Imagen dataset (see below). We add i.i.d. Gaussian noise, smoothed spatially with a Gaussian kernel (σ = 3mm), to model other variability sources. The effect size and the Signal-to-Noise Ratio (SNR) can vary across simulations.

To assess our approach, ten different datasets were generated and were ran on our framework with P=1,000 permutations to compute the different distributions under the null hypothesis. The sparsity threshold was set to raw p-value ≤ 10 -4 , which means that mappers only reports raw p-values that meets this constraint. Four decision statistics were used to control the FWER :

• The min(p) statistic assesses the significance of an association between a SNP and a voxel.

• The total volume statistic is defined as the number of voxels for which the correlation with the SNP is smaller than the sparsity threshold. It assesses whether the volume of the brain associated with an SNP is significant.

• The -log 10 (p) statistic is close from the total volume statistic with the difference that the volume of each voxel is weighted by the strength of the association expressed in log (p-value).

• The cluster volume statistic is defined as the largest number of spatially connected voxels for which the correlation with the SNP is smaller than the sparsity threshold. The difference with the total volume statistic is the connectivity constraint.

For each statistic considered, we report in Table 2 the number of detected SNPs, near detections (i.e. the causal SNP is not detected but a neighbour SNP in LD is) and unique detections (i.e. only one method detect the causal SNP). With no surprise, the min(p) statistic only detects an extreme peak and is far less sensitive than the other methods due to the 2 × 10 10 tests performed. Its main advantage is that of not requiring permutations when used with the Bonferonni FWER correction. Other methods do not consider each SN P × voxel association separately, but assess the impact of an SNP on the whole brain and require permutations to estimate the associated statistical significance. These three methods are more sensitive because the number of tests drops to 5 × 10 5 . In the context @ COMPSTAT 2012 of our simulation, i.e. the spatially extended effect of an SNP is in only one region, the clusterbased analysis gives the best results with the detection of 25 of the 100 causal SNP, including 7 unique detections. The total volume and the sum statistics give close, slightly poorer results and detect some causal SNP missed by the cluster-based analysis. These two methods are probably best suited for detecting spatially extended effects in two regions or more. On real data, all these methods could be complementary depending on the shape and intensity of the effects. A closer look at the results shows that effects with high SNR but confined to small volumes are difficult to detect with all statistics. The volume of the effect is comparable with that of smooth noise areas, so that the SNR level is critical for the sake of detections.

Results on IMAGEN data

We used data from Imagen, a large functional neuroimaging database [START_REF] Schumann | The IMAGEN study: reinforcement-related behaviour in normal brain function and psychopathology[END_REF] containing fMRI associated with 99 different contrast images in more than 1,500 subjects. The dataset is built on the first batch of subjects of the study. Regarding the functional neuroimaging data, the faces protocol [START_REF] Pollak | Early experience is associated with the development of categorical representations for facial expressions of emotion[END_REF] was used, with the [angry faces -neutral] contrast (i.e. the difference between watching angry faces or neutral faces).

Imaging phenotype. Standard preprocessing, including slice timing correction, spike and motion correction, temporal detrending (functional data), and spatial normalization (anatomical and functional data), were performed using the SPM8 software and its default parameters; functional images were resampled at 3mm resolution. Obvious outliers detected using simple rules such as large registration or segmentation errors or very large motion parameters were removed after this step. The [angry faces -neutral] contrast was obtained using a standard linear model, based on the convolution of the time course of the experimental conditions with the canonical hemodynamic reponse function, together with standard high-pass filtering procedure and temporally auto-regressive noise model. The estimation of the model parameters was carried out using the SPM8 software. A mask of the grey matter was built by avergaing and thresholding the individual grey matter probability maps. Subjects with too many missing data (imaging or genetic) or not marked as good in the quality check were discarded. An outliers detection (method described in [START_REF] Fritsch | Detecting outlying subjects in high-dimensional neuroimaging datasets with regularized minimum covariance determinant[END_REF]) was ran and we eliminate 10% of the most outlier subjects.

Genotype. We keep only SNPs with less than 2% missing data. All the remaining missing data were replaced by the median over the subjects for the corresponding variable. The age, the sex and the acquisition center were taken as confounding variables.

The final dataset contains 453 subjects, 51,792 voxels, 494,480 SNPs and 10 confounding variables. Our Map-Reduce framework was run on the this dataset with P=10,000 permutations to assess statistical significance with a good degree of confidence. The sparsity threshold was set to raw p-value ≤ 10 -4 . This choice permits to limit the intermediary results to 200GB, an amount that the NFS filesystem can manage. The workflow takes approximately 50 hours on the previously described 240 cores cluster, for a theoretical serial time around 475 days. We report in Figure 4 only 4 SNPs with the lowest corrected p-values; the genes close to the suprathreshold SNPs are identified with the UCSC genome browser [START_REF] Kent | The human genome browser at UCSC[END_REF]. We also provide views of the effects in the brain for this 4 SNPs.

Only one SNP, rs1021831, is associated with a corrected p-value ≤ 0.05 for 3 of the 4 decision statistics to voxels in the visual cortex. This SNP is in an intergenic region, far from any gene. The second best SNP, rs436760, is only detected by the min(p) statistic with corr. p = 0.14 and it is located in the promoter region of the ADAM28 gene. Associated voxels are in the superior prefrontal cortex. The third SNP, rs7778308, is associated with corr. p ≤ 0.23 for the total volume and sum statistics and is located in the GRM8 gene. Associated voxels are near the intraparietal sulcus. The last SNP, rs8065460, was found by the cluster-size statistic with corr. p = 0.29 and it is located in the promoter region of the ANKFN1 gene. Associated voxels are in the precuneus.

To fulfil the annotation of our findings we used GeneValorization [START_REF] Brancotte | Gene list significance at-a-glance with GeneValorization[END_REF] and search if the found genes were studied in the context of addictions or mental diseases: GRM8 has been associated with alcohol dependence [START_REF] Chen | Association of single nucleotide polymorphisms in a glutamate receptor gene (GRM8) with theta power of event-related oscillations and alcohol dependence[END_REF], anxiety [START_REF] Duvoisin | Opposing roles of mGluR8 in measures of anxiety involving non-social and social challenges[END_REF][START_REF] Robbins | Evaluation of the mGlu8 receptor as a putative therapeutic target in schizophrenia[END_REF], attention deficit hyperactivity disorder [START_REF] Elia | Genome-wide copy number variation study associates metabotropic glutamate receptor gene networks with attention deficit hyperactivity disorder[END_REF], heroin addiction [START_REF] Nielsen | Genotype patterns that contribute to increased risk for or protection from developing heroin addiction[END_REF] and schizophrenia [START_REF] Robbins | Evaluation of the mGlu8 receptor as a putative therapeutic target in schizophrenia[END_REF][START_REF] Takaki | Positive associations of polymorphisms in the metabotropic glutamate receptor type 8 gene (GRM8) with schizophrenia[END_REF]. These preliminary results should be taken with caution and need to be reproduced.

Discussion and conclusion

Cluster-based inference promises large gains in terms of sensitivity to better detect associations between the brain and genetics. But this method requires permutations to assess the statistical significance of results and thus it has a prohibitive cost with popular analysis softwares. In this paper, we present an efficient and scalable framework that can deal with such a computational burden and that we used to provide a realistic assessment of the statistical power of our approach on simulations, which had never been done before. Our results on simulated data highlight the potential of our method and we provide interesting preliminary results on real data, including one association that passes the significance threshold after correction for multiple testing. As far as we know, this is the first time that such a result was obtained in a voxelwise genome-wide association study, although it needs to be reproduced to be considered meaningful.

Our method could be improved following two directions, addressing some drawbacks of the cluster based inference. First, the threshold on the statistical maps is arbitrarily chosen and @ COMPSTAT 2012 has a major impact on the significant clusters found. Methods to avoid this problem exists, like the threshold-free cluster enhancement presented in [START_REF] Smith | Threshold-free cluster enhancement: addressing problems of smoothing, threshold dependence and localisation in cluster inference[END_REF]. Second, image noise is not uniformly smooth, so that larger clusters are expected in smoother areas. Introducing non-stationarity in our simulation would make it more realistic. Methods to limits this problem also exists [START_REF] Salimi-Khorshidi | Adjusting the effect of nonstationarity in cluster-based and TFCE inference[END_REF]. These are promising ways to improve the sensitivity of cluster-based inference.

Another gain in sensitivity could be provided by multivariate models in which the joint variability of several genetic variables is considered simultaneously but would have an impact on computational speed. Such models are thought to be more powerful [START_REF] Vounou | Discovering genetic associations with high-dimensional neuroimaging phenotypes: A sparse reduced-rank regression approach[END_REF][START_REF] Bunea | Penalized least squares regression methods and applications to neuroimaging[END_REF][START_REF] Kohannim | Boosting power to detect genetic associations in imaging using multilocus, genome-wide scans and ridge regression[END_REF][START_REF] Meinshausen | Stability selection[END_REF], because they can express more complex relationships than simple pairwise association models. The cost of unitary fit becomes much higher (due to non-smooth optimization problems and various cross-validation loops needed to optimize the parameters), and moreover, permutation testing is necessary to assess the statistical significance of the results of such procedures. These methods require many efforts to be tractable for our problem on the algorithmic and implementation side as well as in the design of adapted and dimension reduction schemes. This manuscript reflects only the author's views and the Community is not liable for any use that may be made of the information contained therein.

Figure 2 .

 2 Figure 2. Overview of the Map-reduce framework for the neuroimaging-genetics univariate model.

Figure 3 .

 3 Figure 3. Setting and execution of the Map-Reduce algorithm on the cluster.

Figure 4 .

 4 Figure 4. Results of the vGWAS on IMAGEN dataset with the differents methods and corresponding brain localizations. A gene is in bold typeface if the SNP is located in the gene.

Table 1 .

 1 COMPSTAT 2012 Comparison of execution time and speed of Plink and our mapper. Speedup 1 is the speedup against the performance reported in[START_REF] Stein | Voxelwise genome-wide association study (vGWAS)[END_REF], while Speedup 2 is the speedup against Plink with our settings.

	Procedure	GWAS time in sec.	Speed in assoc. per sec.	Speedup 1	Speedup 2
	Plink v1.05 in [10] ∼540	8.30 × 10 2	1	-
	Plink v1.06	∼2	2.24 × 10 5	270	1
	Our mapper	0.081	5.50 × 10 6	6667	25

Table 2 .

 2 Results on the simulated datasets with type I errors control by a FWER ≤ 0.05. The volume is the volume of the effect to find and average SNR is the mean of the signal-to-noise ratio for this effect. Numbers indicates how many causal SNPs were detected, a ' * ' indicates an unique detection, and a '+' indicates a near detection.

	Detections with decision statistic

Acknowledgement

Support of this study was provided by the IMAGEN project, which receives research funding from the European Community's Sixth Framework Program (LSHM-CT-2007-037286) and coordinated project ADAMS (242257) as well as the UK-NIHR-Biomedical Research Centre Mental Health, the MRC-Addiction Research Cluster Genomic Biomarkers, and the MRC program grant Developmental pathways into adolescent substance abuse (93558). This research was also supported by the German Ministry of Education and Research (BMBF grant # 01EV0711).


Sergio Castro
email: sergio.castro@uclouvain.be

Sebastián González
email: s.gonzalez@uclouvain.be

Kim Mens
email: kim.mens@uclouvain.be

Marcus Denker
email: marcus.denker@inria.fr

DynamicSchema: A Lightweight Persistency Framework for Context-Oriented Data Management

Keywords: H.2.1 [Information Systems]: Logical Design-data models; H.2.4 [Information Systems]: Systems Context-Oriented Data Management, Data Access Layer, Dynamic Adaptability, Persistency PREPRINT

While context-oriented programming technology so far has focused mostly on behavioral adaptation, context-oriented data management has received much less attention. In this paper we make a case for the problem of context-oriented data management, using a concrete example of a mobile application. We illustrate some of the issues involved and propose a lightweight persistency framework, called Dynam-icSchema, that resolves some of these issues. The solution consists in a flexible reification of the database schema, as a convenient dynamic data structure that can be adapted at execution time, according to sensed context changes. Implementing our mobile application using this framework enabled us to reduce the complexity of the domain modeling layer, to facilitate the production of code with low memory footprint, and to simplify the implementation of certain scenarios related to context-dependent security concerns.

INTRODUCTION

This paper presents DynamicSchema, a lightweight persistency framework that aims at facilitating the implementation of context-dependent business rules governing the access to application data. In our framework, the data access layer is represented by a conveniently reified data structure. This reified model evolves according to detected context changes.

Although we do not claim that the proposed framework is necessarily the most adequate solution for any possible context-oriented data management scenario, we present a concrete example of the implementation of a mobile application in which the framework successfully helped us to

• decrease the complexity required to implement the domain modeling layer,

• facilitate the production of code with low memory requirements and other resources, and

• facilitate the implementation of certain security concerns, in the presence of dynamic adaptability.

The concrete case study of the context-aware mobile application is presented in Section 2. The case study serves as a basis to illustrate and discuss the merits of the proposed framework. Using some concrete examples from the case study, Section 3 illustrates some typical problems in context-aware applications when interacting with the data access layer. Section 4 then introduces the DynamicSchema framework. It explains the core ideas and illustrates how it can be used to solve the aforementioned problems encountered in the case study. Section 5 presents relevant related work and finally Section 6 presents our conclusions.

CASE STUDY: A MOBILE CITY GUIDE

The MobileCity guide is a touristic application implemented on the Android platform. The objective of this application is to help and inform tourists when visiting an unknown city.

The Data Model

Among others, the MobileCity application offers tourist information on various points of interest (POIs) in a city. Each POI has a (textual) description, an image, as well as some other attributes. As for a POI, each image has a textual description associated with it as well. Furthermore, POIs are organized hierarchically according to their location. For example, the POI Brussels is a child of the POI Belgium. The latter, being a root POI of the application does not have a parent POI.

Each user of the application has its own user profile, which contains among others the preferred language of the user and his age group. The age group can have only two possible values for now: adult and child. This profile influences the actual description that should be shown when browsing the information on POIs and images, so that the language and age group of the description match with those in the user profile. For example, if the user speaks French and is of the age group child, the application will use child-friendly descriptions in French for the POIs and images being shown.

All users have access to a list of predefined POIs (for example, encoded by the tourist office), but they can also add their own new POIs to the database. Newly defined POIs are accessible only to the user profiles under which they were created, since probably they are not of interest to other users of the application. Already existing POIs, on the other hand, are accessible to all users of the application and belong to a Default user profile.

Finally, there is an important security concern. Certain POIs can be marked as restricted (e.g. bars serving alcohol), which means that they should never appear when browsed by a user whose profile belongs to the child age group.

Figure 1 shows a partial physical data model [START_REF] Ambler | Agile Database Techniques[END_REF] of our application. Please note that not all entities and attributes present in our actual implementation have been included, but only those needed to support the discussion in this paper. Although a common rule of thumb when mapping a physical data model to an object model is trying to keep relation multiplicities the same [START_REF] Ambler | Agile Database Techniques[END_REF], we have explicitly decided not to follow this convention for certain context-dependent relations present in our model. For example, in the class diagram of Figure 2, we have not considered the relation between a POI and its description to be a one-to-many, but rather a one-to-one relation. There are many reasons supporting this design decision. First, at any given time in our application, the only description that matters is the one corresponding to the current context or, to be more specific, to the profile of the currently active user (i.e. to the current user's language and age group). Modeling a POI as having only one description has the advantage that objects interacting with it do not have to be aware that in fact there are multiple descriptions, simplifying in this way the implementation. Second, this also contributes to keep the memory footprint low (which is an important requirement in mobile applications), given that a POI or image loaded in memory will contain only one description, instead of a list of all possible descriptions.

The Object Model

Given that we have decided to consider a POI description just as a piece of text, we added this description immediately as an attribute to the POI entity, instead of creating a separate entity as was necessary in the physical data model. The same remark applies to images and their description.

ISSUES WITH DATA MANAGEMENT IN CONTEXT-ORIENTED APPLICATIONS

In this section we take a look at some of the typical problems related to data management that arise in context-oriented applications similar to the one of our case study.

A simple scenario

Suppose we are interested in gathering all image entities from our database. According to the object model described above, we should get only one description per image, determined by the actual context. Also, for efficiency reasons, we would like to fetch the image descriptions from the database at the same time as when the image entities themselves are queried.

To implement these requirements, we implemented a variation of the Listing 1 shows a partial implementation of the ImageTable-Gateway class. This class implements a method getAll (lines 3-13) that returns all images in the database. To do so, it first builds an SQL query (lines 6-9). This query collects the relevant data from the image and image description tables (line 6). Note that this is a parameterized query, since the join condition of the image description table depends on two parameters that will be bound later to the language and age group of the user profile entity sent as parameter (line 9).

Once the query has been built, it is evaluated to obtain a database cursor with its results (line 10) and transforms these results in a list of images. This final step is accomplished by invoking the auxiliary method adaptCursorToList (line 12) of which the implementation is not shown for brevity.

Although in general this can be regarded as an acceptable solution, there are certain issues with this implementation. For example, objects invoking this method must always send context information as a parameter. There are many possible patterns that can be applied to alleviate this issue, but before looking for a solution of this relatively simple problem, let us first consider a slightly more complex scenario.

Dealing with multiple context-dependant concerns

Let us now focus on the POI entities. As in the previous example, we require that whenever a POI entity is retrieved from the database, its description is also retrieved. In addition, in our MobileCity application, when retrieving a POI we should also retrieve its related image and that image's description.

Let us suppose that we are interested in finding all root POIs. Listing 2: Querying all root POI entities, for a given user profile As in the previous example, we provide a PoiTableGateway class (listing 2) that implements some methods to query the POI table. In this class, the method getRootPois returns a list with all the root POIs in the database. The structure of this method is very similar to the getAll method in the ImageTableGateway class. First a query is built (lines 6-18). The relevant data is retrieved from the tables poi, poi description, image and image description (lines 6-7).

We then specify that the join condition with the poi description table depends on two query parameters. These parameters will be bound later to the language and age group of the current user (line 10). Until here the example is very similar to the previous one.

But we also need to add an additional join condition to retrieve the right image description, for the image corresponding to the retrieved POI and according to the language and age group of the current user profile (lines 12-13). To filter the results we add a WHERE clause to include only POIs that do not have a parent (line 15). In addition, according to our requirements we should also filter the POIs themselves according to the active user profile (we need to collect all POIs in the Default user profile plus all the POIs stored in the current user's own profile). We do so by adding to the WHERE clause a condition filtering the POIs according to their user creator (line 16) and to the age group of the current user (lines 17-18).

Discussion

As in the previous example, callers of the getRootPois method should pass context-specific data as a parameter to the method (i.e., the currently active user profile). In addition to that issue, this example has shown an increasing complexity with respect to the first one. Part of the reason for this is the need to be aware of how context changes influence not only the direct relations of a table being queried, but also all transitive relations that participate in the query. If many such relations are present, this produces data access code that quickly becomes difficult to maintain and evolve.

In addition to the complexity of context-dependent relations, we also need to be aware of invariant constraints (e.g., security concerns) that should remain respected in any kind of access to an entity. To illustrate this additional problem, let us recall that in our last example we were querying POI entities and that we explicitly added filters for limiting the access to certain POIs (for children). These filters should be present not only in all direct queries to the POI table, but also whenever querying an entity with a direct or transitive relation with a POI entity.

These additional constraints that need to be added everywhere, quickly lead to heavy code duplication and again to data access code that becomes very difficult to maintain and evolve. To overcome these issues, in the next section we present a solution to some of the problems discussed in this section.

THE DYNAMICSCHEMA FRAMEWORK

Part of the problems shown in section 3 are related to the difficulty in modularizing the application data structure, their data constraints, and their context depending rules. Although some frameworks can help to alleviate some of these problems (see section 5), they do not provide facilities to deal with complex context depending rules.

DynamicSchema alleviates this problem. A database schema is modeled as a dynamic structure that can mutate according to changes in a context. Using some prepackaged routines, applications use this structure to generate required SQL code, so changes on this structure will immediate affect the way data is accessed and manipulated.

The framework architecture

Before showing how DynamicSchema can be used to represent schema objects, we introduce its core classes. Figure 3 shows its class diagram. The Schema class is a repository of database schema objects (limited to table objects only for now).

Modeling a database schema

Listing 3 shows how the poi table can be modeled using our framework. On lines 4-7 we define singleton objects that help us to refer to the table name, its column and relation model. The PoiColumns class (lines 9-18) defines the column model of the table. In this query, the poi table appears twice since the relation is recursive. Then, we need a mechanism to specify which role of the relation the poi table is playing. In SQL this is accomplished with the use of distinct aliases (e.g., p1 and p2 ).

The same join condition shown in the previous SQL example is specified in our framework at line 30 of listing 3. In this line, the expression: Instead, it is an instance of UserDependingRelation, which extends Relation with the addition of a UserProfile instance variable. This class is not part of our framework, but has been added as part of the MobileCity application to model relations which join conditions depend on certain values of the current user profile. In the poiDescription relation, we can see that the join condition depends on the preferred user profile language (line 39) and its age group (line 40).

SQL generative routines

This section provides an intuition of how SQL code is generated from our database model.

In general, our framework navigates and manipulates schema objects through the use of visitors. There are two different kind of visitors pre-packaged in the framework: The TableRelationsVisitor and the SchemaVisitor.

The TableRelationsVisitor visits all the relations, and tables in those relations, of a given base table . The SchemaVisitor visits all the tables and their relations in a given schema.

Extending these generic visitors, we can easily accomplish operations such as generating SQL statements, or modifying certain objects in the schema according to sensed context changes.

The SelectBuilderEagerRelationsVisitor class is an example of how extending TableRelationsVisitor is possible to generate SQL statements. A fragment of this class is shown in list 4. The relation context object passed by at the constructor (line 2) has the knowledge of how tables and column names should be resolved. It basically acts as a SQL alias manager.

Without entering into technical details, the two doVisit methods (lines 7-13 and 15-18) create a query manipulating a query builder object. In DinamicSchema, the structures reifying a database schema are not static, but can vary according to changes in the context.

When the context changes, these schema modifications can be easily implemented with a class extending the SchemaVisitor visitor described in section 4.3.

A visitor updating the schema of the MobileCity application is shown in listing 5. This class overrides the doVisit method (lines 6 to 29) inherited from the SchemaVisitor class. For each visited relation it checks if the relation is an instance of UserDependingRelation (line 9). If that is the case it will set a new user profile (line 10).

If the currently visited relation is in fact the PoiTable base relation (line 11), it modifies the relation filtering conditions. For example, a condition filtering restricted POIs (line 21) is only added after verifying that the current user profile is not the one of an adult (line 20). In addition to the filter conditions generated by the select method, it is possible to include new filters if necessary.

As an example, listing 7 shows an alternative version of the getRootPois method shown in listing 2. If we compare it with the previous implementation, we observe that this method is not parameterized with context information. Also, a query bringing all the POIs from the database is generated with only one line (line 4). We just add a filter condition checking that only POIs with no parents are included (line 6) and all the work for building the query has been done. The rest of the method is similar to the previous version. This example has shown how, with our framework, we can avoid to write boilerplate code related to data access, reduce the need to parameterize persistency methods with context information, and centralize data access rules such as context depending security concerns.

RELATED WORK

Most popular persistency frameworks cannot be easily used in mobile programming. In the Java world (then in the Android world), this is both for the relatively big amount of resources they require, or other technical problems such as a dependency on JDBC (e.g., Hibernate [START_REF] King | Hibernate[END_REF]).

There are lightweight persistency frameworks that can work in mobile devices (e.g., OrmLite [START_REF] Watson | Ormlite[END_REF]) , or are specifically designed for them (e.g., greenDAO [3], ActiveAndroid [START_REF] Pardo | Activeandroid[END_REF]). However, these frameworks are based on the use of annotations or configuration files to map model classes to database tables (e.g., OrmLite, ActiveAndroid), or in code generation techniques to produce once the code that will interact with the database (e.g., greenDAO). Therefore, they consider the database as a static structure where relations are fixed and do not depend on a context.

CONCLUSIONS

In this paper we have illustrated some of the complexity related to context-oriented data management.

As discussed in section 1, part of this complexity is introduced by the presence of context depending mappings between the physical model and the class model. In our case study, the need to use these context depending relations is a direct consequence of the desire of keeping the model simple, minimizing its memory requirements and consistent all the time with the security concerns of the application.

We have shown how with a dynamic structure reifying a database schema, we could simplify the programming of the data access layer implementing these requirements. Furthermore, we show how easily we can update our database schema representation in the case of context changes.

Figure 1 :

 1 Figure 1: The MobileCity Physical Data Model.

Figure 2

 2 Figure 2 shows a class diagram representing the object model of the application, corresponding to the data model of Figure 1.

Figure 2 :

 2 Figure 2: The MobileCity Class Diagram.

1 p u b

  l i c c l a s s P o i T a b l e G a t e w a y extends TableGateway { 2 . . . 3 p u b l i c L i s t <Poi> g e t R o o t P o i s ( U s e r P r o f i l e u s e r ) { 4 S t r i n g i d L a n g u a g e = u s e r . g e t L a n g u a g e ( ) . g e t I d ( ) ; 5 S t r i n g idAgeGroup = u s e r . getAgeGroup ( ) . g e t I d ( ) ; 6 S t r i n g q u e r y = "SELECT p . i d , p . p a r e n t , p . i d u s e r p r o f i l e , p . r e s t r i c t e d , pd . d e s c r i p t i o n , " 7 +"img . i d , img . f i l e n a m e , img . i d p o i , imgd . d e s c r i p t i o n , " 8 +"FROM p o i p " 9 +"LEFT JOIN p o i d e s c r i p t i o n pd ON p . i d = pd . i d p o i " 10 +"AND pd . i d l a n g u a g e = ? AND pd . i d a g e g r o u p = ? " 11 +"LEFT JOIN i m a g e img ON p . i d = img . i d p o i " 12 +"LEFT JOIN i m a g e d e s c r i p t i o n imgd ON img . i d = imgd . i d p o i i m a g e " 13 +"AND imgd . i d l a n g u a g e = ? AND imgd . i d a g e g r o u p = ? " 14 +"JOIN u s e r p r o f i l e up ON p . i d u s e r p r o f i l e = up . i d " 15 +"WHERE p . i d p a r e n t I S NULL " 16 +"AND ( p . i d u s e r p r o f i l e = ? OR up . name= ' D e f a u l t ' ) " ; 17 i f ( ! u s e r . i s A d u l t ( ) ) 18 q u e r y += " AND p . r e s t r i c t e d = 0 " ; 19 C u r s o r c u r s o r = db ( ) . rawQuery ( q u e r y , 20 new S t r i n g [ ] { i d L a n g u a g e , idAgeGroup , 21 i d L a n g u a g e , idAgeGroup , u s e r . g e t I d ( ) } ) ; 22 return a d a p t C u r s o r T o L i s t ( c u r s o r , 0 ) ; 23 } 24 }

Figure 3 :

 3 Figure 3: DynamicSchema Class Diagram.

1

  import s t a t i c a n d r o i d . p r o v i d e r . BaseColumns . I D ; 2 . . . 3 p u b l i c c l a s s P o i T a b l e extends Table<PoiColumns , P o i R e l a t i o n s > { 4 p u b l i c s t a t i c f i n a l S t r i n g NAME = " p o i " ; 5 p u b l i c s t a t i c P o i T a b l e t a b l e = new P o i T a b l e ( ) ; 6 p u b l i c s t a t i c PoiColumns c o l u m n s ( ) { return t a b l e . getColumnModel ( ) ; } ; 7 p u b l i c s t a t i c P o i R e l a t i o n s r e l a t i o n s ( ) { return t a b l e . g e t R e l a t i o n M o d e l ( ) ; } 8 9 p u b l i c s t a t i c c l a s s PoiColumns extends ColumnModel { 10 p u b l i c Column ID = new Column ( I D ) ; 11 p u b l i c Column ID PARENT POI = new Column ( " p a r e n t " ) ; 12 p u b l i c Column ID USER PROFILE = new Column ( " i d u s e r p r o f i l e " ) ; 13 p u b l i c Column RESTRICTED = new Column ( " r e s t r i c t e d " ) ; 14 . . . 15 p u b l i c PoiColumns ( ) { 16 s e t C o l u m n s ( ID , ID PARENT POI , ID USER PROFILE , RESTRICTED, . . . l i c s t a t i c c l a s s P o i R e l a t i o n s extends R e l a t i o n M o d e l { 21 p u b l i c R e l a t i o n c h i l d r e n P o i ; 22 p u b l i c U s e r D e p e n d i n g R e l a t i o n p o i D e s c r i p t i o n ; 23 p u b l i c R e l a t i o n p o i I m a g e ; 24 p u b l i c R e l a t i o n u s e r P r o f i l e ; 25 . . . 26 p u b l i c P o i R e l a t i o n s ( ) { 27 c h i l d r e n P o i = new R e l a t i o n ( t h i s , CHILDREN POI RELATION NAME , F e t c h i n g . LAZY, P o i T a b l e . t a b l e ) ; 28 c h i l d r e n P o i . s e t C o n d i t i o n (new R e l a t i o n C o n d i t i o n ( ) { 29 @ O v e r r i d e p u b l i c S q l C o n d i t i o n e v a l ( I R e l a t i o n a l C o n t e x t M a n a g e r c t x ) { 30 return new S q l C o n d i t i o n ( ) . e q ( b a s e R e l a t i o n . c o l ( c t x , P o i T a b l e . c o l u m n s ( ) . ID ) , c h i l d r e n P o i . c o l ( c t x , P o i T a b l e . c o l u m n s ( ) . ID PARENT POI ) ) ; 31 } 32 } ) ; 33 p o i D e s c r i p t i o n = new U s e r D e p e n d i n g R e l a t i o n ( t h i s , POI DESCRIPTION RELATION NAME , P o i D e s c r i p t i o n T a b l e . t a b l e ) ; 34 p o i D e s c r i p t i o n . s e t C o n d i t i o n (new R e l a t i o n C o n d i t i o n ( ) { 35 @ O v e r r i d e p u b l i c S q l C o n d i t i o n e v a l ( I R e l a t i o n a l C o n t e x t M a n a g e r c t x ) { 36 I n t e g e r l a n g u a g e I d = p o i D e s c r i p t i o n . g e t U s e r P r o f i l e ( ) . g e t I d L a n g u a g e ( ) ; 37 I n t e g e r a g e G r o u p I d = p o i D e s c r i p t i o n . g e t U s e r P r o f i l e ( ) . g e t I d A g e G r o u p ( ) ; 38 S q l C o n d i t i o n c o n d i t i o n = new S q l C o n d i t i o n ( ) . e q ( b a s e R e l a t i o n . c o l ( c t x , P o i T a b l e . c o l u m n s ( ) . ID ) , p o i D e s c r i p t i o n . c o l ( c t x , P o i D e s c r i p t i o n T a b l e . c o l u m n s ( ) . ID POI ) ) 39 . and ( ) . e q ( p o i D e s c r i p t i o n . c o l ( c t x , P o i D e s c r i p t i o n T a b l e . c o l u m n s ( ) . ID LANGUAGE) , l a n g u a g e I d ) 40 . and ( ) . e q ( p o i D e s c r i p t i o n . c o l ( c t x , P o i D e s c r i p t i o n T a b l e . c o l u m n s ( ) . ID AGE GROUP ) , a g e G r o u p I d ) ; 41 42 return c o n d i t i o n ; 43 } 44 } ) ; 45 p o i I m a g e = . . . 46 u s e r P r o f i l e = . . .

  b a s e R e l a t i o n . c o l ( ctx , P o i T a b l e . columns ( ) . ID ) can be read as: The ID column at the poi table in the context of the base relation.In a similar way, the expression:c h i l dr e n P o i . c o l ( ctx , P o i T a b l e . columns ( ) . ID PARENT POI ) can be read as: The PARENT POI column at the poi table in the context of the childrenPoi relation. Now let's focus on the poiDescription relation (lines 33 to 44). Note that this relation is not an instance of the Relation class as all the other relations in the relation model.

1 p u b 4 . 4

 44 l i c c l a s s S e l e c t B u i l d e r E a g e r R e l a t i o n s V i s i t o r extends T a b l e R e l a t i o n s V i s i t o r { 2 p r o t e c t e d I R e l a t i o n a l C o n t e x t M a n a g e r c t x ; 3 p r i v a t e C o n t e x t e d Q u e r y B u i l d e r q u e r y B u i l d e r ; 4 5 p u b l i c S e l e c t B u i l d e r E a g e r R e l a t i o n s V i s i t o r ( I R e l a t i o n a l C o n t e x t M a n a g e r c t x ) { . . . } 6 . . . 7 @ O v e r r i d e p u b l i c boolean d o V i s i t ( R e l i n r e l a t i o n ) { 8 . . . 9 / / a d d i n g r e l a t i o n j o i n c o n d i t i o n s t o t h e q u e r y 10 L e f t J o i n j o i n = new L e f t J o i n ( r e l a t i o n . j o i n C o n d i t i o n ( c t x ) , g e t T a b l e A l i a s e s ( r e l a t i o n ) ) ; 11 q u e r y B u i l d e r . a d d J o i n ( j o i n ) e r r i d e p u b l i c boolean d o V i s i t ( R e l a t i o n r e l a t i o n , T a b l e t a b l e ) { 16 / / a d d i n g c o l u m n s t o t h e q u e r y a n d t a b l e s p e c i f i c f i l t e r c o n d i t i o n s 17 DynamicSchema in action 4.4.1 Adapting the schema to context changes

1 p u b

  l i c c l a s s C o n t e x t C h a n g e d V i s i t o r extends S c h e m a V i s i t o r { 2 p r i v a t e P r o p e r t y C h a n g e E v e n t c h a n g e E v e n t ; 3 p r i v a t e U s e r P r o f i l e d e f a u l t U s e r P r o f i l e ; 4 p u b l i c C o n t e x t C h a n g e d V i s i t o r ( P r o p e r t y C h a n g e E v e n t c h a n g e E v e n t , A b s t r a c t D a t a S o u r c e d a t a S o u r c e ) { . . . } 5 6 @ O v e r r i d e p u b l i c boolean d o V i s i t ( f i n a l R e l a t i o n r e l a t i o n ) { 7 i f ( c h a n g e E v e n t . g e t P r o p e r t y N a m e ( ) . e q u a l s (USER PROFILE CONTEXT CHAN { 8 f i n a l U s e r P r o f i l e n e w U s e r P r o f i l e = ( U s e r P r o f i l e ) c h a n g e E v e n t . getNewValue ( ) ; 9 i f ( r e l a t i o n i n s t a n c e o f U s e r D e p e n d i n g R e l a t i o n ) 10 ( ( U s e r D e p e n d i n g R e l a t i o n ) r e l a t i o n ) . s e t U s e r P r o f i l e ( n e w U s e r P r o f 11 i f ( r e l a t i o n . e q u a l s ( P o i T a b l e . r e l a t i o n s ( ) . g e t B a s e R e l a t i o n ( ) ) ) { 12 f i n a l i n t r e s t r i c t e d = n e w U s e r P r o f i l e . i s A d u l t ( ) ? 0 : 1 ; 13 R e l a t i o n C o n d i t i o n c o n d i t i o n = new R e l a t i o n C o n d i t i o n ( ) { 14 @ O v e r r i d e p u b l i c S q l C o n d i t i o n e v a l ( I R e l a t i o n a l C o n t e x t M a n a g e r c t x ) { 15 S q l C o n d i t i o n s q l C o n d i t i o n = new S q l C o n d i t i o n ( ) ; 16 s q l C o n d i t i o n . g r o u p ( / / p a r e n t h e s e d e x p r e s s i o n 17 new S q l C o n d i t i o n ( ) . e q ( r e l a t i o n . c o l ( c t x , P o i T a b l e . c o l u m n s ( ) . ID USER PROFILE ) , n e w U s e r P r o f i l e . g e t I d ( ) ) 18 . o r ( ) . e q ( r e l a t i o n . c o l ( c t x , P o i T a b l e . c o l u m n s (

1 p u b l i c a b s t r a c t c l a s sListing 6 :

 6 Table<ColumnModelType extends ColumnModel , R e l a t i o n M o d e l T y p e extends R e l a t i o n M o d e l > { 2 . . . 3 p u b l i c C o n t e x t e d Q u e r y B u i l d e r s e l e c t ( ) { 4 I R e l a t i o n a l C o n t e x t M a n a g e r r e l a t i o n a l C o n t e x t = g e t R e l a t i o n a l C o n t e x t ( ) ; 5 S e l e c t B u i l d e r E a g e r R e l a t i o n s V i s i t o r s e l e c t B u i l d e r V i s i t o r = new S e l e c t B u i l d e r E a g e r R e l a t i o n s V i s i t o r ( r e l a t i o n a l C o n t e x t ) ; 6 s e l e c t B u i l d e r V i s i t o r . v i s i t ( t h i s ) ; 7 return s e l e c t B u i l d e r V i s i t o r . g e t Q u e r y B u i l d e r ( ) ; 8 } 9 / / o t h e r q u e r y m e t h o d s . . . 10 } The Table class

1 p u b

  l i c c l a s s P o i T a b l e G a t e w a y extends TableGateway { 2 . . . 3 p u b l i c L i s t <I P o i > g e t R o o t P o i s ( ) { 4 C o n t e x t e d Q u e r y B u i l d e r q u e r y B u i l d e r = P o i T a b l e . t a b l e . s e l e c t ( ) ; 5 I R e l a t i o n a l C o n t e x t M a n a g e r c t x = q u e r y B u i l d e r . g e t R e l a t i o n a l C o n t e x t ( ) ; 6 q u e r y B u i l d e r . addWhere ( P o i T a b l e . t a b l e . g e t B a s e R e l a t i o n ( ) . c o l ( c t x , P o i T a b l e . c o l u m n s ( ) . ID PARENT POI ) + " I S NULL" ) ; 7 C u r s o r c u r s o r = rawQuery ( q u e r y B u i l d e r ) ; 8 return a d a p t C u r s o r T o L i s t ( c u r s o r , 0 , c t x ) ; 9 } 10 } Listing 7: An improved implementation of the PoiTableGateway class

Table Gateway

 Gateway

	user profile
		pattern [2]. In our implemen-
		tation of this pattern, dedicated objects encapsulate certain
		table-level operations such as queries.
	1	p u b l i c c l a s s ImageTableGateway extends TableGateway {
	2	. . .
	3	p u b l i c L i s t <Image> g e t A l l ( U s e r P r o f i l e u s e r ) {
	4	S t r i n g i d L a n g u a g e = u s e r . g e t L a n g u a g e ( ) . g e t I d ( ) ;
	5	S t r i n g idAgeGroup = u s e r . getAgeGroup ( ) . g e t I d ( ) ;
	6	S t r i n g q u e r y = "SELECT img . i d , img . i d p o i ,
		img . f i l e n a m e , imgd . d e s c r i p t i o n "
	7	+"FROM i m a g e img "
	8	+"LEFT JOIN i m a g e d e s c r i p t i o n imgd ON img . i d =
		imgd . i d p o i i m a g e "
	9	+"AND imgd . i d l a n g u a g e =? AND imgd . i d a g e g r o u p =? " ;
	10	C u r s o r c u r s o r = db ( ) . rawQuery ( q u e r y ,
	11	new S t r i n g [ ] { i d L a n g u a g e , idAgeGroup } ) ;
	12	return a d a p t C u r s o r T o L i s t ( c u r s o r , 0 ) ;
	13	}
	14	}
		Listing 1: Querying all images entities, for a given

  LAZYfetching means that the relation should be ignored when querying the base table, since entities in the relation tables will be brought lazily later when needed.The relation condition describes how to match entities in the base table with entities in the relation tables (i.e., a join condition). When a relation condition is specified in the base relation, it will work as a filter that will be applied to all the results of a query involving this table (translated to SQL as a WHERE condition).

Table objects, in addition to a name, have a column model and a relation model. A column model models the columns in a table. The relation model defines a set of relations with other tables. We refer to the table defining the relation model as the base table, to distinguish it from other tables participating in relations with it. Each relation has: a name, the list of tables participating in the relation, a default fetching mode and a relation (join) condition. The fetching mode can take two possible values: EAGER or LAZY. EA-GER fetching means that the relation has to be taken into account when generating a query on the base table.

  The framework provides convenient methods to generate queries. These methods are implemented by the Tableclass. Listing 6 shows an example of one of them: the select method (lines 3 to 8). This method answers an object representing a SQL query. This query is generated with the Se-lectBuilderEagerRelationsVisitor visitor (line 6) described in section 4.3. As mentioned before, this visitor generates a query that will bring, when executed, all the entities persisted on the table. In addition, entities in other tables participating in eager relations with the queried table, are also included in the query.In the generated query, join conditions and other filters are resolved depending on the current state of the relation models of all the Table objects involved.

		) ;
	20	i f ( ! n e w U s e r P r o f i l e . i s A d u l t ( ) )
	21	s q l C o n d i t i o n . and ( ) . n o t ( ) . e q ( r e l a t i o n . c o l ( c t x ,
		P o i T a b l e . c o l u m n s ( ) . RESTRICTED) ,
		r e s t r i c t e d ) ;
	22	return s q l C o n d i t i o n ;
	23	}
	24	} ;
	25	r e l a t i o n . s e t C o n d i t i o n ( c o n d i t i o n ) ;
	26	}
	27	}
	28	return t r u e ;
	29	}
	30	}
		Listing 5: Adapting the schema to context changes
		4.4.2 Querying the schema

) . ID USER PROFILE ) , d e f a u l t U s e r P r o f i l e . g e t I d ( ) )