Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MSpangepop
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pangepop
MSpangepop
Commits
91443da8
Commit
91443da8
authored
4 months ago
by
PIAT LUCIEN
Browse files
Options
Downloads
Patches
Plain Diff
add more documentation
parent
996648d9
No related branches found
Branches containing commit
No related tags found
1 merge request
!10
Wrapped scripts in Snakemake, added SLURM configuration, and revised the variant generation logic.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
workflow/scripts/variants_class.py
+44
-25
44 additions, 25 deletions
workflow/scripts/variants_class.py
with
44 additions
and
25 deletions
workflow/scripts/variants_class.py
+
44
−
25
View file @
91443da8
...
...
@@ -12,10 +12,10 @@ class Variant:
bases
=
[
'
A
'
,
'
C
'
,
'
G
'
,
'
T
'
]
repetition_range
=
(
2
,
3
)
def
__init__
(
self
,
variant_type
,
chrom
,
pos
,
length
=
1
,
reference_seq
=
""
,
samples
=
None
):
def
__init__
(
self
,
variant_type
,
chrom
,
pos
ition
,
length
=
1
,
reference_seq
=
""
,
samples
=
None
):
self
.
variant_type
=
variant_type
self
.
chrom
=
chrom
self
.
pos
=
pos
self
.
pos
ition
=
pos
ition
self
.
length
=
length
self
.
reference_seq
=
reference_seq
self
.
alt_seq
=
""
...
...
@@ -23,72 +23,91 @@ class Variant:
def
compute_alt_seq
(
self
):
#Must be defined in subclasses
pass
raise
NotImplementedError
(
"
Subclasses must implement this method.
"
)
def
reverse_sequence
(
self
,
sequence
):
"""
Reverses a given sequence.
"""
return
sequence
[::
-
1
]
#This is the line in the recap file
def
describe
(
self
):
return
f
"
{
self
.
variant_type
}
\t
{
self
.
chrom
}
\t
{
self
.
pos
}
\t
{
self
.
length
}
\t
{
self
.
reference_seq
[
:
10
]
}
\t
{
self
.
alt_seq
[
:
10
]
}
\t
{
self
.
samples
}
"
"""
Creates a summary line for this variant.
"""
return
f
"
{
self
.
variant_type
}
\t
{
self
.
chrom
}
\t
{
self
.
position
}
\t
{
self
.
length
}
\t
{
self
.
reference_seq
[
:
10
]
}
\t
{
self
.
alt_seq
[
:
10
]
}
\t
{
self
.
samples
}
"
#This is the line printed in the vcf
def
vcf_line
(
self
):
"""
Formats the variant as a line in VCF format.
"""
samples_str
=
'
\t
'
.
join
(
map
(
str
,
self
.
samples
.
values
()))
return
f
"
{
self
.
chrom
}
\t
{
self
.
pos
}
\t
.
\t
{
self
.
reference_seq
}
\t
{
self
.
alt_seq
}
\t
.
\t
PASS
\t
.
\t
GT
\t
{
samples_str
}
"
return
f
"
{
self
.
chrom
}
\t
{
self
.
pos
ition
}
\t
.
\t
{
self
.
reference_seq
}
\t
{
self
.
alt_seq
}
\t
.
\t
PASS
\t
.
\t
GT
\t
{
samples_str
}
"
class
SNP
(
Variant
):
def
__init__
(
self
,
chrom
,
pos
):
super
().
__init__
(
'
SNP
'
,
chrom
,
pos
,
length
=
1
)
def
__init__
(
self
,
chrom
,
pos
ition
):
super
().
__init__
(
'
SNP
'
,
chrom
,
pos
ition
,
length
=
1
)
def
compute_alt_seq
(
self
):
"""
Creates an alternative sequence by changing a single base.
"""
self
.
alt_seq
=
random
.
choice
([
base
for
base
in
self
.
bases
if
base
!=
self
.
reference_seq
])
class
Deletion
(
Variant
):
def
__init__
(
self
,
chrom
,
pos
,
length
):
super
().
__init__
(
'
Deletion
'
,
chrom
,
pos
,
length
)
def
__init__
(
self
,
chrom
,
pos
ition
,
length
):
super
().
__init__
(
'
Deletion
'
,
chrom
,
pos
ition
,
length
)
def
compute_alt_seq
(
self
):
"""
Creates an alternative sequence by keeping only the first base, simulating a deletion.
"""
self
.
alt_seq
=
self
.
reference_seq
[
0
]
class
Insertion
(
Variant
):
def
__init__
(
self
,
chrom
,
pos
,
length
):
super
().
__init__
(
'
Insertion
'
,
chrom
,
pos
,
length
)
def
__init__
(
self
,
chrom
,
pos
ition
,
length
):
super
().
__init__
(
'
Insertion
'
,
chrom
,
pos
ition
,
length
)
def
compute_alt_seq
(
self
):
"""
Creates an alternative sequence by adding random bases.
"""
self
.
alt_seq
=
self
.
reference_seq
+
""
.
join
(
random
.
choice
(
self
.
bases
)
for
_
in
range
(
self
.
length
))
class
Inversion
(
Variant
):
def
__init__
(
self
,
chrom
,
pos
,
length
):
super
().
__init__
(
'
Inversion
'
,
chrom
,
pos
,
length
)
def
__init__
(
self
,
chrom
,
pos
ition
,
length
):
super
().
__init__
(
'
Inversion
'
,
chrom
,
pos
ition
,
length
)
def
compute_alt_seq
(
self
):
"""
Creates an alternative sequence by reversing the reference sequence.
"""
self
.
alt_seq
=
self
.
reverse_sequence
(
self
.
reference_seq
)
class
TandemDuplication
(
Variant
):
def
__init__
(
self
,
chrom
,
pos
,
length
):
super
().
__init__
(
'
TandemDuplication
'
,
chrom
,
pos
,
length
)
def
__init__
(
self
,
chrom
,
pos
ition
,
length
):
super
().
__init__
(
'
TandemDuplication
'
,
chrom
,
pos
ition
,
length
)
def
compute_alt_seq
(
self
):
"""
Creates an alternative sequence by duplicating the reference sequence.
"""
number_of_repeats
=
random
.
randint
(
self
.
repetition_range
[
0
],
self
.
repetition_range
[
1
])
self
.
alt_seq
=
self
.
reference_seq
*
number_of_repeats
class
InvertedTandemDuplication
(
Variant
):
def
__init__
(
self
,
chrom
,
pos
,
length
):
super
().
__init__
(
'
InvertedTandemDuplication
'
,
chrom
,
pos
,
length
)
def
__init__
(
self
,
chrom
,
pos
ition
,
length
):
super
().
__init__
(
'
InvertedTandemDuplication
'
,
chrom
,
pos
ition
,
length
)
def
compute_alt_seq
(
self
):
"""
Creates an alternative sequence by duplicating and reversing the reference sequence.
"""
number_of_repeats
=
random
.
randint
(
self
.
repetition_range
[
0
],
self
.
repetition_range
[
1
])
self
.
alt_seq
=
self
.
reverse_sequence
(
self
.
reference_seq
*
number_of_repeats
)
class
Translocation
(
Variant
):
def
__init__
(
self
,
chrom
,
pos
,
length
):
super
().
__init__
(
'
Translocation
'
,
chrom
,
pos
,
length
)
def
__init__
(
self
,
chrom
,
position
,
length
):
super
().
__init__
(
'
Translocation
'
,
chrom
,
position
,
length
)
def
compute_alt_seq
(
self
):
"""
Placeholder method for translocation type variant.
"""
pass
class
Transduplication
(
Variant
):
def
__init__
(
self
,
chrom
,
pos
,
length
):
super
().
__init__
(
'
Transduplication
'
,
chrom
,
pos
,
length
)
def
__init__
(
self
,
chrom
,
position
,
length
):
super
().
__init__
(
'
Transduplication
'
,
chrom
,
position
,
length
)
def
compute_alt_seq
(
self
):
"""
Placeholder method for transduplication type variant.
"""
pass
class
ReciprocalTranslocation
(
Variant
):
def
__init__
(
self
,
chrom
,
pos
,
length
):
super
().
__init__
(
'
ReciprocalTranslocation
'
,
chrom
,
pos
,
length
)
\ No newline at end of file
def
__init__
(
self
,
chrom
,
position
,
length
):
super
().
__init__
(
'
ReciprocalTranslocation
'
,
chrom
,
position
,
length
)
def
compute_alt_seq
(
self
):
"""
Placeholder method for reciprocal translocation type variant.
"""
pass
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment