Skip to content

Commit

Permalink
MAINT: Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Vini2 committed Aug 23, 2023
1 parent 6eb8b6e commit 277b894
Show file tree
Hide file tree
Showing 10 changed files with 862 additions and 754 deletions.
8 changes: 4 additions & 4 deletions graphbin2
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

"""graphbin2: Refined and overlapped binning of metagenomic contigs using assembly graphs."""

import click
import os
import sys
import logging
import sys

import click

from src import (graphbin2_SPAdes, graphbin2_SGA, graphbin2_Flye)
from src import graphbin2_Flye, graphbin2_SGA, graphbin2_SPAdes

__author__ = "Vijini Mallawaarachchi, Anuradha Wickramarachchi, and Yu Lin"
__copyright__ = "Copyright 2020, GraphBin2 Project"
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import setuptools


with open("README.md", "r") as fh:
long_description = fh.read()

Expand Down Expand Up @@ -30,7 +29,7 @@
entry_points={
"console_scripts": [
"gfa2fasta=src.support.gfa2fasta:main",
"prep_result=src.support.prepResult:main"
"prep_result=src.support.prepResult:main",
],
},
classifiers=[
Expand Down
3 changes: 2 additions & 1 deletion src/bidirectionalmap/bidirectionalmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
answered by user jme
"""


class BidirectionalError(Exception):
"""Must set a unique value in a BijectiveMap."""

Expand Down Expand Up @@ -38,4 +39,4 @@ def _del_item(self, key):
super().__delitem__(key)

def _set_item(self, key, value):
super().__setitem__(key, value)
super().__setitem__(key, value)
50 changes: 25 additions & 25 deletions src/graph_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import re

from Bio import SeqIO

from .bidirectionalmap.bidirectionalmap import BidirectionalMap


def get_contig_lengths_spades(contigs_file):
# Get length and coverage of contigs
contig_lengths = {}
Expand All @@ -11,26 +13,25 @@ def get_contig_lengths_spades(contigs_file):
my_map = BidirectionalMap()

for index, record in enumerate(SeqIO.parse(contigs_file, "fasta")):
start = 'NODE_'
end = '_length'
contig_num = int(re.search('%s(.*)%s' % (start, end), record.id).group(1))
start = '_length_'
end = '_cov'
length = int(re.search('%s(.*)%s' % (start, end), record.id).group(1))
start = '_cov_'
end = ''
coverage = int(float(re.search('%s(.*)%s' % (start, end), record.id).group(1)))
start = "NODE_"
end = "_length"
contig_num = int(re.search("%s(.*)%s" % (start, end), record.id).group(1))

start = "_length_"
end = "_cov"
length = int(re.search("%s(.*)%s" % (start, end), record.id).group(1))

start = "_cov_"
end = ""
coverage = int(float(re.search("%s(.*)%s" % (start, end), record.id).group(1)))

contig_lengths[contig_num] = length
coverages[contig_num] = coverage

return contig_lengths, coverages


def get_contig_paths_spades(contig_paths):

paths = {}
segment_contigs = {}
node_count = 0
Expand All @@ -44,34 +45,33 @@ def get_contig_paths_spades(contig_paths):
with open(contig_paths) as file:
name = file.readline()
path = file.readline()

while name != "" and path != "":

while ";" in path:
path = path[:-2]+","+file.readline()
start = 'NODE_'
end = '_length_'
contig_num = str(int(re.search('%s(.*)%s' % (start, end), name).group(1)))
path = path[:-2] + "," + file.readline()

start = "NODE_"
end = "_length_"
contig_num = str(int(re.search("%s(.*)%s" % (start, end), name).group(1)))

segments = path.rstrip().split(",")

if current_contig_num != contig_num:
my_map[node_count] = int(contig_num)
contig_names[node_count] = name.strip()
current_contig_num = contig_num
node_count += 1

if contig_num not in paths:
paths[contig_num] = [segments[0], segments[-1]]

for segment in segments:
if segment not in segment_contigs:
segment_contigs[segment] = set([contig_num])
else:
segment_contigs[segment].add(contig_num)

name = file.readline()
path = file.readline()

return my_map,
return (my_map,)

0 comments on commit 277b894

Please sign in to comment.