Пример #1
0
    def write_intensities_stream(self, file_name):

        """
        @summary: Writes all intensities to a file

        @param file_name: Output file name
        @type file_name: StringType

        This function loop over all scans, and for each scan
        writes intensities to the file, one intenisity per
        line. Intensities from different scans are joined
        without any delimiters.

        @author: Vladimir Likic
        """

        if not is_str(file_name):
            error("'file_name' must be a string")

        N = len(self.__scan_list)

        print" -> Writing scans to a file"

        fp = open_for_writing(file_name)

        for ii in range(len(self.__scan_list)):
            scan = self.__scan_list[ii]
            intensities = scan.get_intensity_list()
            for I in intensities:
                fp.write("%8.4f\n" % ( I ) )

        close_for_writing(fp)
Пример #2
0
    def write(self, file_name, minutes=False):

        """
        @summary: Writes the ion chromatogram to the specified file

        @param file_name: Output file name
        @type file_name: StringType
        @param minutes: A boolean value indicating whether to write
            time in minutes
        @type minutes: BooleanType

        @return: none
        @rtype: NoneType

        @author: Lewis Lee
        @author: Vladimir Likic
        """

        if not is_str(file_name):
            error("'file_name' must be a string")

        fp = open_for_writing(file_name)

        time_list = copy.deepcopy(self.__time_list)

        if minutes:
            for ii in range(len(time_list)):
                time_list[ii] = time_list[ii]/60.0

        for ii in range(len(time_list)):
            fp.write("%8.4f %#.6e\n" % (time_list[ii], self.__ia[ii]))

        close_for_writing(fp)
Пример #3
0
    def write_intensities_stream(self, file_name):

        """
        @summary: Writes all intensities to a file

        @param file_name: Output file name
        @type file_name: StringType

        This function loop over all scans, and for each scan
        writes intensities to the file, one intenisity per
        line. Intensities from different scans are joined
        without any delimiters.

        @author: Vladimir Likic
        """

        if not is_str(file_name):
            error("'file_name' must be a string")

        N = len(self.__scan_list)

        print" -> Writing scans to a file"

        fp = open_for_writing(file_name)

        for ii in range(len(self.__scan_list)):
            scan = self.__scan_list[ii]
            intensities = scan.get_intensity_list()
            for I in intensities:
                fp.write("%8.4f\n" % ( I ) )

        close_for_writing(fp)
Пример #4
0
    def write(self, file_name, minutes=False):

        """
        @summary: Writes the ion chromatogram to the specified file

        @param file_name: Output file name
        @type file_name: StringType
        @param minutes: A boolean value indicating whether to write
            time in minutes
        @type minutes: BooleanType

        @return: none
        @rtype: NoneType

        @author: Lewis Lee
        @author: Vladimir Likic
        """

        if not is_str(file_name):
            error("'file_name' must be a string")

        fp = open_for_writing(file_name)

        time_list = copy.deepcopy(self.__time_list)

        if minutes:
            for ii in range(len(time_list)):
                time_list[ii] = time_list[ii]/60.0

        for ii in range(len(time_list)):
            fp.write("%8.4f %#.6e\n" % (time_list[ii], self.__ia[ii]))

        close_for_writing(fp)
Пример #5
0
    def write(self, file_root):

        """
        @summary: Writes the entire raw data to two files, one
            'file_root'.I.csv (intensities) and 'file_root'.mz.csv
            (m/z values).

            This method writes two CSV files, containing intensities
            and corresponding m/z values. In general these are not
            two-dimensional matrices, because different scans may
            have different number of m/z values recorded.

        @param file_root: The root for the output file names
        @type file_root: StringType

        @author: Vladimir Likic
        """

        if not is_str(file_root):
            error("'file_root' must be a string")

        file_name1 = file_root + ".I.csv"
        file_name2 = file_root + ".mz.csv"

        print " -> Writing intensities to '%s'" % ( file_name1 )
        print " -> Writing m/z values to '%s'" % ( file_name2 )

        fp1 = open_for_writing(file_name1)
        fp2 = open_for_writing(file_name2)

        for ii in range(len(self.__scan_list)):

            scan = self.__scan_list[ii]

            intensity_list = scan.get_intensity_list()
            mass_list = scan.get_mass_list()

            for ii in range(len(intensity_list)):
                v = intensity_list[ii]
                if ii == 0:
                    fp1.write("%.4f" % (v))
                else:
                    fp1.write(",%.4f" % (v))
            fp1.write("\n")

            for ii in range(len(mass_list)):
                v = mass_list[ii]
                if ii == 0:
                    fp2.write("%.4f" % (v))
                else:
                    fp2.write(",%.4f" % (v))
            fp2.write("\n")

        close_for_writing(fp1)
        close_for_writing(fp2)
Пример #6
0
    def write(self, file_root):

        """
        @summary: Writes the entire raw data to two files, one
            'file_root'.I.csv (intensities) and 'file_root'.mz.csv
            (m/z values).

            This method writes two CSV files, containing intensities
            and corresponding m/z values. In general these are not
            two-dimensional matrices, because different scans may
            have different number of m/z values recorded.

        @param file_root: The root for the output file names
        @type file_root: StringType

        @author: Vladimir Likic
        """

        if not is_str(file_root):
            error("'file_root' must be a string")

        file_name1 = file_root + ".I.csv"
        file_name2 = file_root + ".mz.csv"

        print " -> Writing intensities to '%s'" % ( file_name1 )
        print " -> Writing m/z values to '%s'" % ( file_name2 )

        fp1 = open_for_writing(file_name1)
        fp2 = open_for_writing(file_name2)

        for ii in range(len(self.__scan_list)):

            scan = self.__scan_list[ii]

            intensity_list = scan.get_intensity_list()
            mass_list = scan.get_mass_list()

            for ii in range(len(intensity_list)):
                v = intensity_list[ii]
                if ii == 0:
                    fp1.write("%.4f" % (v))
                else:
                    fp1.write(",%.4f" % (v))
            fp1.write("\n")

            for ii in range(len(mass_list)):
                v = mass_list[ii]
                if ii == 0:
                    fp2.write("%.4f" % (v))
                else:
                    fp2.write(",%.4f" % (v))
            fp2.write("\n")

        close_for_writing(fp1)
        close_for_writing(fp2)
Пример #7
0
    def export_leco_csv(self, file_name):

        """
        @summary: Exports data in LECO CSV format

        @param file_name: File name
        @type file_name: StringType

        @return: none
        @rtype: NoneType

        @author: Andrew Isaac
        @author: Vladimir Likic
        """

        if not is_str(file_name):
            error("'file_name' is not a string")

        mass_list = self.__mass_list
        time_list = self.__time_list
        vals = self.__intensity_matrix

        fp = open_for_writing(file_name)

        # Format is text header with:
        # "Scan","Time",...
        # and the rest is "TIC" or m/z as text, i.e. "50","51"...
        # The following lines are:
        # scan_number,time,value,value,...
        # scan_number is an int, rest seem to be fixed format floats.
        # The format is 0.000000e+000

        # write header
        fp.write("\"Scan\",\"Time\"")
        for ii in mass_list:
            if is_number(ii):
                fp.write(",\"%d\"" % int(ii))
            else:
                error("mass list datum not a number")
        fp.write("\r\n")  # windows CR/LF

        # write lines
        for ii in range(len(time_list)):
            fp.write("%s,%#.6e" % (ii, time_list[ii]))
            for jj in range(len(vals[ii])):
                if is_number(vals[ii][jj]):
                    fp.write(",%#.6e" % (vals[ii][jj]))
                else:
                    error("datum not a number")
            fp.write("\r\n")

        close_for_writing(fp)
Пример #8
0
    def export_leco_csv(self, file_name):

        """
        @summary: Exports data in LECO CSV format

        @param file_name: File name
        @type file_name: StringType

        @return: none
        @rtype: NoneType

        @author: Andrew Isaac
        @author: Vladimir Likic
        """

        if not is_str(file_name):
            error("'file_name' is not a string")

        mass_list = self.__mass_list
        time_list = self.__time_list
        vals = self.__intensity_matrix

        fp = open_for_writing(file_name)

        # Format is text header with:
        # "Scan","Time",...
        # and the rest is "TIC" or m/z as text, i.e. "50","51"...
        # The following lines are:
        # scan_number,time,value,value,...
        # scan_number is an int, rest seem to be fixed format floats.
        # The format is 0.000000e+000

        # write header
        fp.write("\"Scan\",\"Time\"")
        for ii in mass_list:
            if is_number(ii):
                fp.write(",\"%d\"" % int(ii))
            else:
                error("mass list datum not a number")
        fp.write("\r\n")  # windows CR/LF

        # write lines
        for ii in range(len(time_list)):
            fp.write("%s,%#.6e" % (ii, time_list[ii]))
            for jj in range(len(vals[ii])):
                if is_number(vals[ii][jj]):
                    fp.write(",%#.6e" % (vals[ii][jj]))
                else:
                    error("datum not a number")
            fp.write("\r\n")

        close_for_writing(fp)