Skip to content

Commit

Permalink
added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszChilinski committed Mar 28, 2022
1 parent 84e53fd commit 391e827
Show file tree
Hide file tree
Showing 78 changed files with 19,620 additions and 29 deletions.
35 changes: 35 additions & 0 deletions SVTools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class SVariant:
"""Class representing structural variant."""
def __init__(self, tool, line=None, chrom=None, pos=None, id=None, ref=None, end=None, gt=None, svlen=None, svtype=None, cipos1=None, cipos2=None, ciend1=None, ciend2=None, algorithms=None):
self.tool = tool
if(line is not None):
Expand All @@ -19,6 +20,11 @@ def __init__(self, tool, line=None, chrom=None, pos=None, id=None, ref=None, end
self.used = False
self.algorithms = algorithms
def printVcfLine(self):
"""Creates a line for the entry in VCF file for particular SV.
Returns:
str: Line entry for VCF file.
"""
sv_len = self.svlen
end = self.end
if(self.svtype == "INS" or self.svtype == "DUP"):
Expand All @@ -28,6 +34,11 @@ def printVcfLine(self):
return '\t'.join((self.chrom, str(self.pos), self.id, self.ref, "<"+self.svtype+">",
".", "PASS", "END="+str(end)+";SVLEN="+str(sv_len)+";SVTYPE="+self.svtype+";ALGORITHM="+self.algorithms+";CIPOS="+str(self.cipos1)+","+str(self.cipos2)+";CIEND="+str(self.ciend1)+","+str(self.ciend2), "GT", self.gt, "\n"))
def parse_line(self, line):
"""Parses a line from VCF file, and uses that information for the SVariant initialisation.
Args:
line (str): Line from the VCF file.
"""
values = line.split("\t")
self.chrom = values[0]
self.pos = int(values[1])
Expand Down Expand Up @@ -64,6 +75,14 @@ def parse_line(self, line):

self.used = False
def parse_type(self, svtype):
"""Parses type of the SV.
Args:
svtype (str): Type from the INFO field.
Returns:
_type_: Uniform type of SV.
"""
if "del" in svtype.casefold():
return "DEL"
if "inv" in svtype.casefold():
Expand All @@ -78,8 +97,17 @@ def parse_type(self, svtype):
return "CNV"
return "UNK"
def print_sv(self):
"""Print the SV in the console. Used mostly for debugging."""
print(self.svtype + ": " + self.chrom + " " + str(self.pos) + "(" + str(self.cipos1) +", " + str(self.cipos2) + ")" + " - " + str(self.end) + "(" + str(self.cipos1) +", " + str(self.cipos2) + ")" + " LEN: " + str(self.svlen) + " GT: " + self.gt)
def checkOverlap(self, sv2):
"""Checks overlap between SVariants.
Args:
sv2 (SVariant): Variant to overlap.
Returns:
bool: Information whether the variants overlap or not.
"""
if(self.chrom != sv2.chrom):
return False
# bear in mind that cipos first coord is negative, hence just addition (example cipos=-10,10)
Expand All @@ -104,11 +132,18 @@ def checkOverlap(self, sv2):
return False

class SVTool:
"""Class for storing the SV callers."""
max_conf = 200 # max confidence interval length
"""Maximum confidence interval."""
def __init__(self, filename):
self.tool = filename.split("/")[-1].split(".")[0]
self.parse_file(filename)
def parse_file(self, filename):
"""Function for parsing the VCF file.
Args:
filename (str): Name of the VCF file for particular tool.
"""
self.sv_list = list()
with open(filename) as file:
for line in file:
Expand Down
15 changes: 12 additions & 3 deletions charles_filter_n.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
"""Script for generating accuracy metrics between the gold set and the SVs created by ConsensuSV."""

import re
import argparse
import os

from subprocess import Popen, PIPE
parser = argparse.ArgumentParser(description='Extracts sample.')

parser = argparse.ArgumentParser(description='Extracts sample.')
"""Parser for the arguments to the script."""
parser.add_argument('-s', '--samples', help='Samples name to compare (comma-separated).', required=True)
parser.add_argument('-o', '--outputs', help='Our files (generated by consensuSV, comma-separated).', required=True)

args = parser.parse_args()
"""Arguments to the script."""



our_callers = set(['lumpy', 'VH', 'wham', 'Manta', 'Delly']) # + cnvnator, breakseq, breakdancer
"""Callers used in gold set & our tool (intersection)."""

samples = args.samples.split(',')
outputs = args.outputs.split(',')
"""Samples to compare."""

outputs = args.outputs.split(',')
"""Output files from ConsensuSV."""
if os.path.exists('charles_pass'):
os.remove('charles_pass')
if os.path.exists('charles_pass'):
os.remove('charles_pass')

i = 0
"""Iterator"""
for sample in samples:
open('charles_pass','w').writelines([ line for line in open('ALL_Illumina_Integrate_20170206.vcf') if 'PASS' in line or '#' in line])
open('charles_pass2','w').writelines([ line for line in open('charles_pass') if sample in line or '#' in line])

full_text = ""
"""Full text from gold set."""
with open('charles_pass2', 'r') as f:
for line in f:
if not('#' in line):
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
4 changes: 4 additions & 0 deletions docs/build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 282ead6f489089e892512bba2a5c5ccd
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docs/build/html/.doctrees/autoapi/index.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docs/build/html/.doctrees/environment.pickle
Binary file not shown.
Binary file added docs/build/html/.doctrees/index.doctree
Binary file not shown.
87 changes: 87 additions & 0 deletions docs/build/html/_sources/autoapi/SVTools/index.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
:py:mod:`SVTools`
=================

.. py:module:: SVTools
Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

SVTools.SVariant
SVTools.SVTool




.. py:class:: SVariant(tool, line=None, chrom=None, pos=None, id=None, ref=None, end=None, gt=None, svlen=None, svtype=None, cipos1=None, cipos2=None, ciend1=None, ciend2=None, algorithms=None)
Class representing structural variant.

.. py:method:: printVcfLine(self)
Creates a line for the entry in VCF file for particular SV.

Returns:
str: Line entry for VCF file.


.. py:method:: parse_line(self, line)
Parses a line from VCF file, and uses that information for the SVariant initialisation.

Args:
line (str): Line from the VCF file.


.. py:method:: parse_type(self, svtype)
Parses type of the SV.

Args:
svtype (str): Type from the INFO field.

Returns:
_type_: Uniform type of SV.


.. py:method:: print_sv(self)
Print the SV in the console. Used mostly for debugging.


.. py:method:: checkOverlap(self, sv2)
Checks overlap between SVariants.

Args:
sv2 (SVariant): Variant to overlap.

Returns:
bool: Information whether the variants overlap or not.



.. py:class:: SVTool(filename)
Class for storing the SV callers.

.. py:attribute:: max_conf
:annotation: = 200

Maximum confidence interval.


.. py:method:: parse_file(self, filename)
Function for parsing the VCF file.

Args:
filename (str): Name of the VCF file for particular tool.



56 changes: 56 additions & 0 deletions docs/build/html/_sources/autoapi/charles_filter_n/index.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
:py:mod:`charles_filter_n`
==========================

.. py:module:: charles_filter_n
.. autoapi-nested-parse::

Script for generating accuracy metrics between the gold set and the SVs created by ConsensuSV.



Module Contents
---------------

.. py:data:: parser
Parser for the arguments to the script.


.. py:data:: args
Arguments to the script.


.. py:data:: our_callers
Callers used in gold set & our tool (intersection).


.. py:data:: samples
Samples to compare.


.. py:data:: outputs
Output files from ConsensuSV.


.. py:data:: i
:annotation: = 0

Iterator


.. py:data:: full_text
:annotation: =

Full text from gold set.


59 changes: 59 additions & 0 deletions docs/build/html/_sources/autoapi/conf/index.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
:py:mod:`conf`
==============

.. py:module:: conf
Module Contents
---------------

.. py:data:: project
:annotation: = ConsensuSV-core



.. py:data:: copyright
:annotation: = 2022, Mateusz Chiliński, Dariusz Plewczyński



.. py:data:: author
:annotation: = Mateusz Chiliński, Dariusz Plewczyński



.. py:data:: release
:annotation: = 1.7



.. py:data:: extensions
:annotation: = ['autoapi.extension']



.. py:data:: autoapi_dirs
:annotation: = ['../../']



.. py:data:: templates_path
:annotation: = ['_templates']



.. py:data:: exclude_patterns
:annotation: = []



.. py:data:: html_theme
:annotation: = sphinx_rtd_theme



.. py:data:: html_static_path
:annotation: = ['_static']



16 changes: 16 additions & 0 deletions docs/build/html/_sources/autoapi/index.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
API Reference
=============

This page contains auto-generated API reference documentation [#f1]_.

.. toctree::
:titlesonly:

/autoapi/charles_filter_n/index
/autoapi/input/index
/autoapi/utilities/index
/autoapi/SVTools/index
/autoapi/main/index
/autoapi/conf/index

.. [#f1] Created with `sphinx-autoapi <https://github.com/readthedocs/sphinx-autoapi>`_
Loading

0 comments on commit 391e827

Please sign in to comment.