{ "info": { "author": "Ad115", "author_email": "a.garcia230395@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: Education", "Intended Audience :: Information Technology", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3 :: Only", "Topic :: Scientific/Engineering :: Artificial Life", "Topic :: Scientific/Engineering :: Bio-Informatics", "Topic :: Scientific/Engineering :: Medical Science Apps." ], "description": "\nWhat is the ICGC-data-parser?\n=============================\n\n|Documentation Status|\n\n.. |Documentation Status| image:: https://readthedocs.org/projects/icgc-data-parser/badge/?version=develop\n :target: http://icgc-data-parser.readthedocs.io/en/develop/?badge=develop\n\nA library to ease the parsing of data from the International Cancer Genome \nConsortium data releases, in particular, the simple somatic mutation \naggregates.\n\n\nTutorial\n======== \n\nInstallation\n------------\n\nInstall via `PyPI `__:\n\n::\n\n $ pip install ICGC_data_parser\n\n\nData download\n-------------\n\nThe base data for the scripts is the ICGC's aggregated of the simple\nsomatic mutation data. Which can be downloded using\n\n::\n\n wget https://dcc.icgc.org/api/v1/download?fn=/current/Summary/simple_somatic_mutation.aggregated.vcf.gz\n\nTo know more about this file, please read `About the ICGC's simple\nsomatic mutations\nfile `__\n\n**WARNING**: The current release of the data contains a malformed\nheader that causes the library to crash with an ``IndexError``::\n\n ---------------------------------------------------------------------------\n ValueError Traceback (most recent call last)\n ~/.local/lib/python3.6/site-packages/vcf/parser.py in _parse_info(self, info_str)\n 389 try:\n ...\n ...\n ...\n 362 def _parse_info(self, info_str):\n\n ValueError: could not convert string to float: 'PCAWG'\n\nThis is caused by a bad type specification in the header of the \nVCF file. To solve it, use the lollowing line after creating the \n``SSM_Reader`` object (asuming the reader is in the ``reader`` \nvariable)\n\n.. code-block:: python\n\n # Fix weird bug due to malformed description headers\n reader.infos['studies'] = reader.infos['studies']._replace(type='String')\n\nIn the future this will be solved in a more elegant way, but for \nnow this is what we've got.\n\n\nUsage\n-----\n\nThe main class in the project is the `SSM_Reader \n`__. \nIt allows to read easily the ICGC mutations file:\n\n.. code:: python\n\n\n >>> from ICGC_data_parser import SSM_Reader\n\n # Reads also compressed files!\n >>> reader = SSM_Reader(open('data/simple_somatic_mutations.aggregated.vcf.gz'))\n\n # or...\n >>> reader = SSM_Reader(filename='data/simple_somatic_mutations.aggregated.vcf.gz')\n # ^^^^^^^^\n # The filename keyord argument is important, else we get an IndexError\n\n\nThe `SSM_Reader.parse \n`__ \nmethod allows to iterate through the records of the file and access the parts \nof the record. You can also specify regular expressions to filter only the \nlines you want:\n\n.. code:: python\n\n\n # Print only the mutations that are in the\n # European Union Breast Cancer project (BRCA-EU).\n\n >>> for record in reader.parse(filters=['BRCA-EU']):\n ... print(record.ID, record.CHROM, record.POS)\n\n MU66865518 1 100141201\n MU65487875 1 100160548\n MU66281118 1 100638179\n MU66254120 1 101352655\n ...\n\nThe INFO field is special in the sense that it contains several\nsubfields, AND those subfields may be list-like entries with more\nsubfields themselves (in particular the CONSEQUENCE and OCCURRENCE\nsubfields):\n\n.. code:: python\n\n\n # The subfields of the INFO field:\n >>> next(reader).INFO\n\n {'CONSEQUENCE': [\n '||||||intergenic_region||', \n 'CD1A|ENSG00000158477|+|CD1A-001|ENST00000289429||upstream_gene_variant||'\n ], \n 'OCCURRENCE': [\n 'ESAD-UK|1|301|0.00332', \n 'EOPC-DE|1|202|0.00495', \n 'BRCA-EU|1|569|0.00176'\n ],\n 'affected_donors': 3, \n 'mutation': 'T>A', \n 'project_count': 3, \n 'studies': None, \n 'tested_donors': 12068}\n\n.. code:: python\n\n\n # The description of the CONSEQUENCE subfield\n >>> print(reader.infos['CONSEQUENCE'].desc)\n\n Mutation consequence predictions annotated by SnpEff \n (subfields: gene_symbol|gene_affected|gene_strand|transcript_name|transcript_affected|protein_affected|consequence_type|cds_mutation|aa_mutation)\n\n\n.. code:: python\n\n\n # The description of the OCCURRENCE subfield\n >>> print(reader.infos['OCCURRENCE'].desc)\n\n Mutation occurrence counts broken down by project \n (subfields: project_code|affected_donors|tested_donors|frequency)\n\n\nSometimes we want to also parse the information in those subfields. For\nthis purpose, the ``SSM_Reader.subfield_parser`` factory method is\nuseful. This method creates a parser of the specified subfield that\nallows easy access to the data:\n\n.. code:: python\n\n\n # Create the subfield parser for the CONSEQUENCE subfield\n >>> consequences = reader.subfield_parser('CONSEQUENCE')\n\n\n >>> for record in reader.parse():\n ... # Which genes are affected?\n ... genes_affected = {c.gene_symbol \n ... for c in consequences(record)\n ... if c.gene_affected}\n ...\n ... print(f'Mutation: {record.ID}')\n ... print('\\t', \", \".join(genes_affected))\n\n Mutation: MU93246178\n TPM3\n Mutation: MU66962994\n RP11-350G8.9, SHE\n Mutation: MU93246498\n DCST1, ADAM15, RP11-307C12.11\n Mutation: MU66377106\n EFNA3, ADAM15, EFNA4\n ...\n\nThe library also contains some helper scripts to manipulate VCF files\n(like the ICGC mutations file): \n\n- ``vcf_map_assembly.py``: Creates a new VCF with the positions mapped to \n another genome assembly. This is useful because currently the positions \n reported by ICGC are in the human genome assembly GRCh37, while the most recent\n (and the one the rest of the world uses) is the GRCh38 assembly. \n\n- ``vcf_sample.py``: Creates a new VCF with a fraction of the mutations in the\n original. The mutations are randomly sampled but maintain the order they had in\n the original file. This is useful when one wants to make small test analysis on\n the data, but still wants the results to be representative of all the \n mutations. \n\n- ``vcf_split.py``: Splits the input VCF into several (also valid VCFs),\n this is useful in case one wants to split the analyses into processes\n that receive one file each.\n\nThe specific documentation of the scripts can be obtained by executing:\n\n::\n\n $ python3