A computer-implemented method for the identification of compounds in complex biological or environmental samples, characterised in that it comprises: receiving raw mass spectrum data from a mass spectrometry analysis coupled with a separation technique applied to a sample, wherein the raw mass spectrum data comprises a plurality of data points with information on retention time, mass-to-charge ratio measured (m/z) and intensity of the signal measured; consulting a molecular formula database which includes the theoretical mass-to-charge ratio (m/z) T of the molecular ion of a plurality of molecular formulas and ionisation adducts; for each data point of the raw mass spectrum data, annotating in an annotation database the combinations of molecular formulas and ionisation adducts the theoretical mass-to-charge ratio (m/z) T of which corresponds to the mass-to-charge ratio (m/z) measured of said data point considering a given mass error, wherein each annotation includes the retention time and the intensity of the measured signal of the data point; for each molecular formula and ionisation adduct annotated in the annotation database, detecting regions of interest defined in a retention time range (RT 0 -RT 1) wherein the annotated data points meet characterisation criteria, wherein detecting regions of interest comprises: determining candidate regions defined in a retention time range (RT C0 -RT C1) with a minimum number of data points and/or a minimum density of data points annotated; characterising the candidate regions, obtaining characterisation parameters; and selecting those candidate regions the characterisation parameters of which meet certain characterisation criteria as regions of interest; generating an inclusion list which includes the retention time ranges (RT 0 -RT 1) of the detected regions of interest and the theoretical mass-to-charge ratios (m/z) T of the molecular formulas and ionisation adducts associated with each of the regions of interest; sending the inclusion list to a mass spectrometer for the identification of compounds in the sample by means of tandem mass spectrometry; and performing a tandem mass spectrometry analysis using the information comprised in the inclusion list in order to identify compounds in the sample. receiving raw mass spectrum data from a mass spectrometry analysis coupled with a separation technique applied to a sample, wherein the raw mass spectrum data comprises a plurality of data points with information on retention time, mass-to-charge ratio measured (m/z) and intensity of the signal measured; consulting a molecular formula database which includes the theoretical mass-to-charge ratio (m/z) T of the molecular ion of a plurality of molecular formulas and ionisation adducts; for each data point of the raw mass spectrum data, annotating in an annotation database the combinations of molecular formulas and ionisation adducts the theoretical mass-to-charge ratio (m/z) T of which corresponds to the mass-to-charge ratio (m/z) measured of said data point considering a given mass error, wherein each annotation includes the retention time and the intensity of the measured signal of the data point; for each molecular formula and ionisation adduct annotated in the annotation database, detecting regions of interest defined in a retention time range (RT 0 -RT 1) wherein the annotated data points meet characterisation criteria, wherein detecting regions of interest comprises: determining candidate regions defined in a retention time range (RT C0 -RT C1) with a minimum number of data points and/or a minimum density of data points annotated; characterising the candidate regions, obtaining characterisation parameters; and selecting those candidate regions the characterisation parameters of which meet certain characterisation criteria as regions of interest; determining candidate regions defined in a retention time range (RT C0 -RT C1) with a minimum number of data points and/or a minimum density of data points annotated; characterising the candidate regions, obtaining characterisation parameters; and selecting those candidate regions the characterisation parameters of which meet certain characterisation criteria as regions of interest; generating an inclusion list which includes the retention time ranges (RT 0 -RT 1) of the detected regions of interest and the theoretical mass-to-charge ratios (m/z) T of the molecular formulas and ionisation adducts associated with each of the regions of interest; sending the inclusion list to a mass spectrometer for the identification of compounds in the sample by means of tandem mass spectrometry; and performing a tandem mass spectrometry analysis using the information comprised in the inclusion list in order to identify compounds in the sample.