Introduction

Halal is defined as “lawful” or “permissible” in Islam and refers to anything that is allowed under Islamic law1. For the food to be considered halal, it must comply with certain criteria such as the ingredients must be free of porcine and its derivatives, animal blood sources, human sources such as an extract from urine or collagen, any alcohol or intoxicating material, and carcasses or improperly slaughtered meat, as mentioned in the Al-Quran2,3. In Islam, it is utmost important to ensure that food is completely free from pork and its derivatives and one effective way to achieve this is by detecting the presence of porcine DNA4,5,6. Additionally, Judaism prohibits the consumption of pork based on the dietary law known as kashrut outlined in the Torah while certain Christian denominations like Seventh-day Adventists and Ethiopian Orthodox Christians prohibit the intake of pork based on their interpretation of biblical teachings7,8,9,10. In addition, Rastafarians also often exclude pork and processed food as they adhere to a dietary law called “ital” which emphasizes natural and clean eating11,12. Aside from that, other groups that avoid pork include Mandaeans, vegetarians, and vegans, as well as certain Chinese communities that adhere to Taoist or Buddhist dietary practices13,14,15. In summary, many communities follow dietary restrictions that prohibit the consumption of pork and its by-products.

Porcine DNA refers to the genetic material derived from pigs, including any trace amounts that may remain in food products after processing. The presence of porcine DNA in halal food indicates that there is an existence of substances from pigs added intentionally or due to cross contamination from other materials produced on the same production line, which are not permitted to be consumed by certain communities previously mentioned especially Muslims16,17. Therefore, it is important to check the presence of halal logo of certification body accredited from accreditation body or from a government agency which certify halal products or recognise halal certification bodies such as JAKIM in Malaysia. The halal logo is one of the indicators that the food products are free from pork and its derivatives18,19. Additionally, verifying both the ingredients and processing aids helps ensure the absence of any pork-derived components. Despite the implementation of halal certification, some manufacturers have misused halal labels and counterfeit logos for their own benefits, leading to regulatory actions against them20. Moreover, porcine DNA have been detected in certain samples labeled with halal logo21,22,23,24. Several studies have also found porcine DNA and wild boar in food items without being disclosed in the ingredient list25,26. These violations are not only serious but offensive especially to halal consumers, all of which conclude that the determination of porcine DNA in food products is vital.

Several current established methods are widely used in the industry to detect the presence of porcine DNA in food samples including polymerase chain reaction (PCR), real-time PCR (qPCR), Fourier-transform infrared spectroscopy (FTIR), high-performance liquid chromatography (HPLC), gas chromatography (GC), digital PCR, enzyme-linked immunosorbent assay (ELISA), next-generation sequencing (NGS), and loop-mediated isothermal amplification (LAMP)20,27,28,29. However, these techniques have their advantages and limitations. For instance, PCR, which is commonly utilized for the detection of porcine DNA requires specialized equipment and trained personnel in the laboratory. Besides that, there are also risks of contamination, whether during manufacturing, sampling, or laboratory handling which can lead to false positives in the results30. qPCR is another method that is frequently used for porcine DNA detection, and it is known to be more advanced than conventional PCR but is more expensive and demands specialized equipment. The ELISA method is suitable for large-scale screening process, but it can only detect proteins, is time-consuming, and requires high costs31. Apart from that, the LAMP is known to be a cost-effective and rapid method but is less sensitive compared to qPCR. On the other hand, the NGS can provide a comprehensive analysis, but it is costly, time-consuming, and requires advanced bioinformatics expertise32. Chromatographic methods such as HPLC and GC are also employed in food analysis to identify porcine-related components, such as specific fats, metabolites, or peptides. These methods provide high precision and sensitivity but are generally labor-intensive, require complex sample preparation, and involve expensive instrumentation and skilled operators33. While each method has its strength, they also have inherent limitations. To address these challenges, this study proposes a novel approach utilizing fuzzy logic to determine the presence of porcine DNA by interpreting the cycle threshold (Ct) value. While fuzzy logic does not replace detection techniques such as ELISA, it enhances decision-making by interpreting molecular data such as Ct values derived from qPCR.

Fuzzy logic (FL) is an Artificial Intelligence algorithm specifically designed to analyze imprecise and uncertain data, enabling it to make critical decisions. FL has been chosen in this study due to its accuracy, versatility, flexibility, and consistency in the decision-making process2. It is particularly valuable in handling ambiguous inputs, simplify processes, and allow easy rule modification when necessary. In addition, FL has demonstrated superior accuracy compared to other AI methods such as adaptive neuro-fuzzy inference systems, deep learning, and artificial neural networks34. FL has been widely used in food industry for various applications including quality control, food safety, classification, food sorting, and prediction35. For example, Sarkar et al. have applied FL to mathematically adjust the sensory scores of Rasgullas based on parameters such as color, flavor, taste, and mouthfeel, ultimately ranking the samples with varying pineapple powder content36. FL has also been employed to evaluate supply chain practices and performance within the food industry37. Additionally, Oganesyants et al. have demonstrated FL’s effectiveness in assessing food safety and quality38. Aryaee et al. have used FL algorithms and the fuzzy toolbox to optimize fruit juice mixtures and quantitatively produce the sensory data39. Furthermore, research has shown that FL can determine the safety of canned food products based on their preservative content40. Fuzzy logic model was also utilized to assess the taste quality of frozen gonads41. Despite its extensive applications in food industry, no study has yet explored the use of FL in detecting porcine DNA through cycle threshold (Ct) values in food products, making this a key feature of this work.

In this study, a fuzzy logic (FL) framework has been developed to detect the presence of porcine DNA in food products based on the Ct values of four target genes namely cytochrome B, 18 s RNA, 12 s RNA, and D-Loop Mitochondria. The framework not only identifies the presence of porcine DNA but also quantifies it by categorizing the Ct values into high, moderate, or low. A user-friendly graphical user interface was also developed to enhance usability, allowing straightforward data entry and rapid result interpretation. This system can assist stakeholders such as laboratory technicians at food safety authorities, port health inspectors, halal certification officers, and halal auditors by enabling faster and more reliable detection of porcine DNA in food samples. Moreover, it provides a user-friendly platform for auditors to independently cross-verify Ct values reported in laboratory documentation, enhancing transparency and supporting compliance verification during inspections. The FL framework and GUI are designed to benefit industry players, auditors, and researchers by providing a robust and interpretable tool for porcine DNA detection. For researchers, it offers a transparent structure that can be adapted for further development or integrating to future smart sensing systems. For auditors, it enables independent verification of sample results through direct input of Ct values, supporting inspection and compliance processes.

This is the introduction section followed by the methodology of the research study in section 2. Next, results and discussion are described in section 3 while the final section concludes the overall findings of the research.

Results

Sample analysis

Several samples were sent to the laboratory to obtain cycle threshold (Ct) values for food products containing porcine DNA, as well as standard Ct values for porcine DNA at different concentrations. The laboratory-obtained Ct values for pork balls, pork sausages, and burger patties are presented in Table 1, while the Ct values from the standard curve analysis of porcine DNA at varying amount are shown in Table 2.

Table 1 Ct Value for Sample Analysis
Table 2 Ct Value for Different Amount of Porcine DNA

Effectiveness of fuzzy logic framework

To evaluate the effectiveness of the developed FL framework, an initial test was conducted using randomly selected values. These values were manually generated within the expected Ct range (1–40) for each target gene, simulating potential real-world input scenarios not previously used to train or design the model. A total of 24 values were inserted into the framework for different target genes, and the results confirmed that the system successfully identified both the presence and quantity of porcine DNA. The results are shown in Table 3 for Ct values of different target genes. Figure 1 illustrates the rule inference of the framework where the outputs are displayed based on the given input.

Fig. 1
figure 1

Fuzzy logic rule inference.

Table 3 Fuzzy logic framework validation using random values

The framework was further tested with the Ct values obtained from the laboratory analysis including samples containing porcine DNA, and the values obtained at different concentrations of porcine as shown in Tables 1 and 2. The results obtained from the FL framework are shown in Table 4 for the food samples and Table 5 for different concentrations of porcine DNA.

Table 4 FL validation by using samples containing porcine DNA
Table 5 FL validation by using different concentrations of porcine DNA

Effectiveness of developed graphical user interface

The graphical user interface (GUI), developed based on the FL framework, was tested to demonstrate its effectiveness in detecting the presence of porcine DNA. The GUI efficiently processed input data and displayed results in the output section, clearly indicating whether porcine DNA was present. As shown in Figs. 2 and 3, when Ct values are less than 40, the output displays “YES,” confirming the presence of porcine DNA. Conversely, for Ct values greater than 40, the output shows “NO,” indicating its absence.

Fig. 2
figure 2

Results confirming the presence of DNA porcine using the graphical user interface.

Fig. 3
figure 3

Results confirming the absence of DNA porcine using the graphical user interface.

Discussion

The FL was able to identify the presence of porcine DNA and its amount when the Ct values of pork balls, pork burger patties, and pork sausages were inserted into the system. Besides that, the FL framework accurately detected porcine DNA and estimated its quantity when Ct values at 1 ng,0.1 ng,0.01 ng,0.001 ng, and 0.0001 ng were inserted. These results confirm the developed framework is effective in determining both the presence and quantity of porcine DNA based on Ct values. The results obtained from the analysis showed that the Ct values for positive porcine DNA range from 13 to 40. As the amount of DNA in the sample increases, the Ct value decreases. This is in line with previous studies conducted by several researchers, which also demonstrated that Ct values decrease as the amount of porcine DNA in food increases42,43,44. The target gene utilized in the developed FL framework was the D-Loop mitochondrial gene similar with the laboratory analysis. When the Ct values for the pork balls which are 13.79,13.88, and 14.20 were inserted into the framework, the output obtained was 0.226, 0.226, and 0.228, respectively for the presence of porcine DNA. These values fall under the ‘YES’ category which indicates that porcine DNA is presence inside the samples. The results indicated that the pork balls consistently fell under the ‘high’ category, signifying a high concentration of porcine DNA in the samples.

Another sample that tested positive for porcine DNA from the laboratory analysis was pork burger patties, which had Ct value readings of 17.81, 15.01, and 16.65. These values were then input into the FL framework, and the output confirmed that the samples fell under the ‘YES’ category, indicating the presence of porcine DNA. Additionally, the readings were classified as belonging to the ‘high’ amount category. Similarly, pork sausages also tested positive for porcine DNA, with Ct readings of 11.94, 12.66, and 12.41. These values were used to further assess the effectiveness of the developed framework. The outputs generated by the system were 0.228, 0.224, and 0.225, all of which fell under the ‘YES’ category for porcine DNA presence and were classified as ‘high’ in terms of concentration.

The FL framework was further tested using Ct values obtained from laboratory analysis for different concentrations of porcine DNA: 1 ng, 0.1 ng, 0.01 ng, 0.001 ng, and 0.0001 ng. The Ct values from these analyses ranged from 20 to 36 and were input into the FL system to evaluate its ability to detect porcine DNA and estimate its amount. The framework successfully classified all outputs under the ‘YES’ category, confirming the presence of porcine DNA in the samples. Additionally, the FL framework categorized the detected amounts as ‘high’ or ‘average/low’, depending on the Ct values. In conclusion, the results validate that the FL framework can effectively determine the presence and concentration of porcine DNA based on Ct values. The outcome from GUI aligns perfectly with the fuzzy logic rules embedded in the framework, validating its accuracy and reliability.

The developed fuzzy logic (FL) framework successfully determines the presence of porcine DNA based on Ct values. However, several limitations present opportunities for future improvements. Currently, the system relies on only four target genes, and its accuracy could be further improved by incorporating additional target genes associated with porcine DNA detection. Future research could also explore the integration of advanced AI techniques, such as deep neural networks (DNNs) and artificial neural networks (ANNs), to improve data processing and classification performance. A key limitation lies in the lack of detailed methodological data from the external laboratory, particularly regarding DNA extraction techniques, equipment used, and whether sample dilution was performed prior to qPCR. While concentration values were provided for each sample, the absence of standard dilution protocol documentation introduces uncertainty, as dilution can influence Ct values and, consequently, the output of the fuzzy logic framework. To address this, future studies should consider conducting in-house laboratory procedures or ensure complete metadata is available when using external analyses to improve reproducibility and model consistency. Additionally, the current fuzzy logic framework does not incorporate supporting quality control indicators such as DNA purity ratios (A260/A280), concentration, or inhibition controls. This may limit the system’s ability to distinguish between true negatives and false negatives, in cases where high Ct values result from low DNA quality or matrix interference rather than the absence of porcine DNA. Incorporating such metadata or refining the rule base to account for these variables could improve classification reliability. Furthermore, comparative analysis of SYBR Green and TaqMan-based qPCR methods may help evaluate the generalizability of the FL model across different amplification platforms and protocols. Lastly, the framework could be further improved by incorporating sensor technology, enabling real-time, on-site detection of porcine DNA without laboratory dependence. This advancement would allow users to instantly determine the presence of porcine DNA, making the system more practical and accessible in commercial and regulatory settings.

In conclusion, a fuzzy logic framework was successfully developed to detect and quantify porcine DNA based on cycle threshold (Ct) values, utilizing MATLAB 2024a. The framework, built using the Mamdani inference system, incorporates four key input genes: Cytochrome B, 18sRNA, 12sRNA, and D-Loop Mitochondria. The outputs provide crucial information regarding both the presence and quantity of porcine DNA. Various test values were used to validate the framework’s effectiveness, demonstrating its accuracy and reliability in determining porcine DNA levels based on Ct values. Additionally, the integration of a graphical user interface (GUI) significantly enhances the system’s usability. The GUI allows users to input data and obtain results without requiring technical expertise in MATLAB, making the detection process more accessible and user-friendly. The intuitive interface streamlines the workflow, enabling users to quickly analyze samples and determine porcine DNA levels with ease. For future improvements, this system could be integrated with sensor technology, allowing for real-time detection of porcine DNA and further enhancing efficiency and practicality.

Methods

Sample Preparation

Various processed meat products including chicken sausage, chicken burger patty, beef meatballs, beef pepperoni, pork sausage, pork burger patty, and pork meatballs were collected from local retail outlets and sent to a certified external laboratory for porcine DNA analysis using real-time PCR (qPCR). The analysis targeted the mitochondrial gene, which is widely recognized for its high copy number and sensitivity in detecting porcine DNA in processed food products. To ensure specificity, the laboratory employed porcine-specific primers with TaqMan probes labeled with FAM dye. The qPCR analysis was conducted using the AriaMx Real-Time PCR System (Agilent Technologies) under standard molecular diagnostic conditions. The reaction included an annealing temperature of 60 °C, 40 amplification cycles, and a detection threshold of 0.001%. Fluorescence detection was performed within a wavelength range of 463 to 516 nm, and the assay reported 100% amplification efficiency based on a five-point standard curve ranging from 1 ng to 0.0001 ng, with a slope of –3.322 and R² of 0.979. While the concentration values were reported in nanograms (ng), the laboratory did not specify whether these referred to ng per microliter (ng/µL) or ng per reaction volume. DNA quantification was carried out using a spectrophotometric method, as evidenced by the A260/A280 and A260/A230 absorbance ratios in the laboratory report. Although the laboratory did not provide further details on the DNA extraction method or sample dilution, the analysis was conducted according with validated and accredited food testing protocols.

Fuzzy logic development

The design of the fuzzy logic framework to the determine the porcine DNA based on the target gene involves several stages. It begins with data collection from journals and laboratory analysis. This is followed by the development of fuzzy logic (FL) framework in MATLAB 2024a, which is then tested using the available data to assess its readiness. The FL framework was subjected to rigorous testing with various datasets to evaluate its effectiveness. Once the outputs of the fuzzy logic framework align with the expected results, the framework is considered ready to be used. Figure 4 illustrates the overall flowchart for this study.

Fig. 4
figure 4

Development of fuzzy logic.

Data preparation

Data preparation is the initial step in developing the fuzzy logic framework for detecting porcine DNA in processed meat products. Here, the essential information on how porcine DNA in meat products can be identified is gathered. In real-time PCR analysis, the cycle threshold (Ct) value plays a critical role in determining the presence and concentration of porcine DNA. A higher value of Ct indicates a lower concentration of porcine DNA in the meat products, while a lower Ct value indicates a higher concentration. The Ct values that signify the presence of porcine DNA have been identified and compiled for four different target genes as summarized in Table 6. The target genes involved here were Cytochrome B, 18sRNA, 12sRNA, and D-Loop Mitochondria. Data collected from various studies confirmed that porcine DNA was consistently detected when Ct values fell within the range of 1 to 40 across all four genes. This said range was subsequently utilized in developing the FL framework presented in this work. While the Ct categories (low, medium, high) in the fuzzy model support interpretability, they are qualitative and not directly calibrated against absolute DNA concentrations or % content of porcine material.

Table 6 Cycle threshold for four target genes

Fuzzy logic framework

Following data collection, the fuzzy logic framework was developed by incorporating three key processes namely fuzzification, fuzzy inference, and defuzzification45. Fuzzification is the process where the crisp input values are converted into fuzzy sets by using membership function46,47,48. The FL framework was implemented using MATLAB 2024a with the target genes serving as inputs and the presence and quantity of porcine DNA as outputs. A triangular membership function was selected as the input membership function while the trapezoidal membership function was selected as the output membership function for enhancing simplicity and accuracy49,50. The triangular membership function was chosen as it effectively represents three distinct levels which are high, low, and medium allowing flexible parameters adjustments if necessary40. Additionally, these membership functions enable easy modification of parameters ranges for future refinements. Their efficiency makes them suitable for large-scale applications and real-time analysis. Overall, the flexibility, interpretability, simplicity, and accuracy of these membership functions make them well-suited for this work51.

Three linguistic variables were set as the inputs, which are low, medium, and high for all the four target genes, representing Ct value readings corresponding to low, medium, and high levels respectively. For the presence of DNA output, two linguistic variables were defined, which are YES and NO. YES signifies the presence of porcine DNA in the food sample, while NO confirms its absence. The second output which is the amount of porcine DNA utilized the membership function of high, medium, and low. High indicates a significant amount of porcine DNA in the sample, medium/low represents a lower concentration, and zero confirms the complete absence of porcine DNA. The structure of the fuzzy logic system, including the selected membership functions for inputs and outputs, is illustrated in Fig. 2.

Type I Mamdani inference system was selected for the development of FL framework due to its ability to determine output values based on input data classification52,53,54. This system is also more user-friendly than other alternatives, offering easier interpretation, flexible rule modification, and enhanced comprehensibility. Moreover, Mamdani inference is recognized for its robustness and is widely considered a superior choice for classification tasks compared to other fuzzy logic systems55. By leveraging this approach, the study effectively achieves its objective of detecting the presence of porcine DNA in the samples. Figure 5 illustrates the overall design of the developed fuzzy logic framework.

Fig. 5
figure 5

Fuzzy logic design.

Fuzzy rules were then established to facilitate the determination of porcine DNA in food products. A total of twelve fuzzy rules were developed for the FL framework, incorporating IF-THEN decision logic. This approach enhances the efficiency of the decision-making process, allowing for a more systematic and accurate classification of porcine DNA presence. The fuzzy rules are tabulated in Table 7.

Table 7 Development of fuzzy logic rules

The final step in the development of the FL framework is defuzzification, where aggregated fuzzy sets are transformed into crisp values56,57. Centroid method was selected for the defuzzification process due to its ability to produce more precise and reliable output results58. The formula used for the defuzzification process is given in Eq. 1 (Jain et al., 2022)59.

$${\rm{Centroid}}=(\Sigma {\rm{xi}}.{\rm{\mu }}({\rm{xi}}))/\,({\rm{\Sigma \; \mu }}({\rm{xi}}))$$
(1)

Where, xi is a value in the universe of discourse,

μ(xi) is the membership function value at xi,

Fuzzy logic testing and validation

The FL framework was initially tested using several random values to ensure its reliability and accuracy. If the output aligned with the expected results, the framework is considered to be valid as shown in Table 2. To further validate the framework, it was tested using data from previous studies and laboratory analyses. In cases where the output did not meet the expected results, both the framework and its coding were thoroughly reviewed and corrected as needed.

Development of a graphical user interface

A graphical user interface (GUI) was then developed based on the FL framework to streamline the process of determining the presence of porcine DNA using Ct values. This interface was designed to be user-friendly, particularly for individuals who may not be familiar with software like MATLAB. By using the GUI, users can analyze food samples without needing to enter commands or execute code, making the process more accessible.

The GUI was built based on the FL framework, ensuring that the rules integrated into the interface remain consistent with those used in the FL framework. The interface includes input fields for Ct values, with an adjacent results box displaying the fuzzy logic system’s output, indicating the presence or absence of porcine DNA. A “Process” button initiates the process, while a “Reset” button clears the input fields for new entries. Figure 6 illustrates the GUI designed for porcine DNA determination using the FL framework.

Fig. 6
figure 6

Graphical user interface for porcine DNA determination.