Changes between Version 1 and Version 2 of AccessingMSEntryFromAnnotationModule


Ignore:
Timestamp:
06/19/2018 09:33:28 PM (3 years ago)
Author:
sena
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AccessingMSEntryFromAnnotationModule

    v1 v2  
    9696
    9797This generic ProjectExplorerDialog can be used anywhere to allow users to select a specific type of Entry. It is generally linked to a "Browse" button to let the users choose an Entry.
     98
     99Once the MS entry or MS entries to be annotated are selected as shown above, their annotation files can be read and used in an annotation module. Please check [wiki:GritsEntryProperty] before proceeding to understand the Entry and Property model used in GRITS. MS entry is an Entry object whose Property is of class MassSpecProperty and has type MassSpecProperty.TYPE. Each Property object can have a list of datafiles (List<PropertyDataFile> dataFiles). For MassSpecProperty, there is a single file which is the msMetadata.xml file. Here is a snippet from MassSpecProperty class (see org.grits.toolbox.entry.ms.property.MassSpecProperty):
     100
     101{{{
     102
     103public class MassSpecProperty extends Property {
     104        // 01/12/18:  CInternal Standard Quant was added to the MetaData. No changes to the property, but this affects the reader but was able to keep at ver 1.3
     105        public static final String CURRENT_VERSION = "1.3";
     106        private static final Logger logger = Logger.getLogger(MassSpecProperty.class);
     107        public static final String TYPE = "org.grits.toolbox.property.ms";
     108        protected static MassSpecPropertyWriter writer = new MassSpecPropertyWriter();
     109        private static final String folderName = "ms";
     110
     111        protected static ImageDescriptor imageDescriptor = ImageRegistry.getImageDescriptor(Activator.PLUGIN_ID, ImageRegistry.MSImage.MASSSPEC_ICON);
     112        public static String CONVERT_RAW = "<to be generated by GRITS>";
     113
     114        private MassSpecMetaData msSettings = null;
     115....
     116}
     117}}}
     118
     119msMetadata.xml file mentioned above is the serialization of msSettings (MassSpecMetaData) field shown in the code snippet. The references to the annotation files/raw files/quantification files etc. are all stored in this MassSpecMetaData (extends MassSpecUISettings) object.
     120
     121{{{
     122public abstract class MassSpecUISettings {
     123        ...
     124        private List<MSPropertyDataFile> fileList;
     125        ...
     126}}}
     127
     128For an annotation module, we are mostly interested in getting the annotation files from the MS Entry. This can be done as follows once you have access to the property object:
     129
     130{{{
     131Property prop = msEntry.getProperty();
     132List<MSPropertyDataFile> files = ((MassSpecProperty) prop).getMassSpecMetaData().getAnnotationFiles();
     133}}}
     134
     135After accessing all the annotation files (there might be multiple), the user can choose the one to be used for annotation.
     136
     137Last step is to be able to read the annotation file (mzxml/mzml file). The following code snippet (see org.grits.toolbox.ms.annotation.gelato package and org.grits.toolbox.importer.ms.annotation.glycan.simiansearch.handler.NewGelatoHandler) shows how to obtain a reader for MzXML file and read the scans from the file:
     138
     139{{{
     140MSPropertyDataFile dataFile = // the user's selection for the annotation file from the list obtained above
     141String workspaceLocation = PropertyHandler.getVariable("workspace_location");
     142String projectName = DataModelSearch.findParentByType(msEntry, ProjectProperty.TYPE).getDisplayName();
     143String pathToFile = workspaceLocation + projectName + File.separator + MassSpecProperty.getFoldername();
     144
     145MSFile msFile = dataFile.getMSFileWithReader(pathToFile, prop.getMassSpecMetaData().getMsExperimentType());
     146if (msFile.getReader() != null && msFile.getReader() instanceof IMSAnnotationFileReader) {  // it must be
     147       List<Scan> scans = ((IMSAnnotationFileReader) msFile.getReader()).readMSFile(msFile);
     148}
     149
     150}}}
     151
     152There are several other methods that might be usable in IMSAnnotationFileReader interface:
     153
     154{{{
     155public interface IMSAnnotationFileReader extends IMSFileReader {
     156        /**
     157         * @param file MS file to be read
     158         * @return List of {@link org.grits.toolbox.ms.om.Scan} from the given MS file
     159         */
     160        List<Scan> readMSFile (MSFile file);
     161       
     162        /**
     163         * get a list of all MSn scans for the given parent scan
     164         *
     165         * @param file MS file to be read
     166         * @param scanNumber scan number to be read
     167         * @return List of {@link org.grits.toolbox.ms.om.Scan} from the given MS file for the given scan number
     168         */
     169        List<Scan> readMSFile (MSFile file, int scanNumber);
     170       
     171        /**
     172         * readMSFile: general method to read an mzXML file for a specific parent scan and scan.
     173         *
     174         * NOTE: will not currently read the entire contents of an MS file. You have to specify at least one of
     175         * msLevel, parentScanNum, or scanNum
     176         *
     177         * @param file  MS file to be read
     178         * @param msLevel  the MS level of scans to load from MS file. Use -1 if to be ignored.
     179         * @param parentScanNum  the scan number to be read, along with its sub-scans. Use -1 if to be ignored.
     180         * @param scanNum  the scan number to be read, ignoring all other data.  Use -1 if to be ignored.
     181         * @return List<Scan> a list of {@link org.grits.toolbox.ms.om.data.Scan} objects
     182         *
     183         */
     184        List<Scan> readMSFile(MSFile file, int msLevel, int parentScanNum, int scanNum);
     185       
     186        /**
     187         *
     188         * @param file MS file to be read
     189         * @param scanNumber parent scan number
     190         * @return List of scan numbers from the given MS file for the given parent scan number
     191         */
     192        List<Integer> getScanList (MSFile file, int scanNumber);
     193       
     194        /**
     195         * getMaxScanNumber: returns the last scan number of the MS file.
     196         * 
     197         * @param file MS file to be read
     198         * @return value of last scan number
     199         */
     200        Integer getMaxScanNumber (MSFile file);
     201       
     202        /**
     203         * returns the lowest scan number
     204         * @param file MS file to be read
     205         * @return value of the first scan number
     206         */
     207        Integer getMinScanNumber(MSFile file);
     208       
     209        /**
     210         * return the minimum MS Level from the file
     211         *
     212         * @param file MS file to be read
     213         * @return minimum MS Level
     214         */
     215        Integer getMinMSLevel(MSFile file);
     216       
     217        /**
     218         * checks whether the file has MS1 scan
     219         *
     220         * @param file MS file to be read
     221         * @return true if there is MS1 scan, false otherwise
     222         */
     223        boolean hasMS1Scan(MSFile file);
     224       
     225        ...
     226}
     227}}}
     228
     229For the object model, please check [wiki:MSObjectModel]