Reading xiNET/xiVIEW Exported Result Files
from pyXLMS import __version__
print(f"Installed pyXLMS version: {__version__}") Installed pyXLMS version: 1.8.1from pyXLMS import parser
from pyXLMS import transformAll functionality to parse results exported from xiNETΒ or xiVIEWΒ is available via the parser submodule. We also import the transform submodule to show some summary statistics of the read files.
Reading xiNET/xiVIEW Files via parser.read()
parser_result = parser.read(
"../../data/xiview/DDX39B_LCSDA_shared_links_open_clamped.csv",
engine="xiNET/xiVIEW",
crosslinker="SDA",
) Reading xiNET/xiVIEW CSMs...: 100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 124/124 [00:00<00:00, 11206.02it/s]We can read any file exported from xiNET or xiVIEW using the parser.read() method and setting engine="xiNET/xiVIEW". The method also requires us to specify the used crosslinker, in this case SDA was used (crosslinker="SDA"). You can read the documentation for the parser.read() method here: docs.
for k, v in parser_result.items():
print(f"{k}: {type(v) if isinstance(v, list) else v}") data_type: parser_result
completeness: partial
search_engine: xiNET/xiVIEW
crosslink-spectrum-matches: <class 'list'>
crosslinks: NoneThe parser.read() method returns a dictionary with a set of specified keys and their values. We refer to this dictionary as a parser_result object. All parser.read* methods return such a parser_result object, you can read more about that here: docs, and here: data types specification.
As you can see from the parser_result the xiVIEW exported file contained CSMs. We would be able to access those via parser_result["crosslink-spectrum-matches"]. We will do this a bit further down.
_ = transform.summary(parser_result) Number of CSMs: 124.0
Number of unique CSMs: 124.0
Number of intra CSMs: 106.0
Number of inter CSMs: 18.0
Number of target-target CSMs: 53.0
Number of target-decoy CSMs: 18.0
Number of decoy-decoy CSMs: 53.0
Minimum CSM score: 5.416106
Maximum CSM score: 20.5163With the transform.summary() method we can also print out some summary statistics about our read CSMs. You can read more about the method here: docs.
sample_csm = parser_result["crosslink-spectrum-matches"][0]
for k, v in sample_csm.items():
print(f"{k}: {v}") data_type: crosslink-spectrum-match
completeness: partial
alpha_peptide: MTPVGTASNVKAQAAKEAQHAQLVAVAEDK
alpha_modifications: None
alpha_peptide_crosslink_position: 1
alpha_proteins: ['DECOY_decoy:P11940']
alpha_proteins_crosslink_positions: [1]
alpha_proteins_peptide_positions: [1]
alpha_score: None
alpha_decoy: True
beta_peptide: TVAPTAAAAAAARPPGMTQTSTNAR
beta_modifications: None
beta_peptide_crosslink_position: 1
beta_proteins: ['DECOY_decoy:P11940']
beta_proteins_crosslink_positions: [131]
beta_proteins_peptide_positions: [131]
beta_score: None
beta_decoy: True
crosslink_type: intra
score: 20.280395
spectrum_file:
scan_nr: 20
charge: 6
retention_time: None
ion_mobility: None
additional_information: {'source': {'Id': 20, 'Protein1': 'DECOY_decoy:P11940', 'SeqPos1': 131, 'PepPos1': 131, 'PepSeq1': 'TVAPTAAAAAAARPPGMoxTQTSTNAR', 'LinkPos1': 1, 'Protein2': 'DECOY_decoy:P11940', 'SeqPos2': 1, 'PepPos2': 1, 'PepSeq2': 'MoxTPVGTASNVKAQAAKEAQHAQLVAVAEDK', 'LinkPos2': 1, 'Score': 20.280395, 'PrecursorIntensity': None, 'Charge': 6, 'ExpMz': 946.325674, 'ExpMass': 5671.910385198726, 'CalcMz': 946.324781, 'CalcMass': 5671.905027198725, 'MassError': 0.9446561560267144, 'Missing Peaks': 0, 'Validated': None, 'Search': 45585, 'RawFileName': None, 'PeakListFileName': None, 'ScanNumber': None, 'ScanIndex': None, 'CrossLinkerModMass': 195.125929, 'FragmentTolerance': None, 'IonTypes': '[{"type":"PeptideIon"},{"type":"BIon"},{"type":"YIon"}]', 'Decoy1': 1, 'Decoy2': 1, '3D Distance': None, 'From Chain': None, 'To Chain': None, 'LinkType': 'Self', 'DecoyType': 'DD', 'Retention Time': None}}Using parser_result["crosslink-spectrum-matches"][0] we can get the first CSM of the file and take a closer look at that.
Here is an example CSM, you can learn more about the specific attributes and their values here: docs, and here: data types specification.
type(parser_result["crosslinks"]) NoneTypeIn this example parser_result["crosslinks"] is None because this file did not contain any crosslinks. This is infered from the available columns in the xiNET/xiVIEW exported file. The parser will check if any spectrum-level information is present in the file and if yes, it will try to parse it as crosslink-spectrum-matches - if no, it will try to parse it as crosslinks. Therefore in this case, no crosslinks can be displayed here.
If you need crosslinks but have crosslink-spectrum-matches, please check on how to aggregate them here: docs.
Reading xiNET/xiVIEW Result Files via parser.read_xinet()
parser_result = parser.read_xinet(
"../../data/xiview/DDX39B_LCSDA_shared_links_open_clamped.csv"
) Reading xiNET/xiVIEW CSMs...: 100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 124/124 [00:00<00:00, 15044.22it/s]We can also read any file exported by xiNET or xiVIEW using the parser.read_xinet() method which allows a more nuanced control over reading the files - even though theoretically everything can be done with the parser.read() function as well. You can read the documentation for the parser.read_xinet() method here: docs.
_ = transform.summary(parser_result) Number of CSMs: 124.0
Number of unique CSMs: 124.0
Number of intra CSMs: 106.0
Number of inter CSMs: 18.0
Number of target-target CSMs: 53.0
Number of target-decoy CSMs: 18.0
Number of decoy-decoy CSMs: 53.0
Minimum CSM score: 5.416106
Maximum CSM score: 20.5163We get the same result as with the parser.read() method!
Reading xiNET/xiVIEW Result Files via parser.read_xiview()
parser_result = parser.read_xiview(
"../../data/xiview/DDX39B_LCSDA_shared_links_open_clamped.csv"
) Reading xiNET/xiVIEW CSMs...: 100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 124/124 [00:00<00:00, 11352.29it/s]We can also read any file exported by xiNET or xiVIEW using the parser.read_xiview() method. This method is just a shorthand function for parser.read_xinet() for convenience, internally both functions execute the same code as the xiNET and xiVIEW exported files share a lot of the same columns.