Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug #5

Open
Smeds opened this issue May 17, 2021 · 0 comments
Open

Possible bug #5

Smeds opened this issue May 17, 2021 · 0 comments

Comments

@Smeds
Copy link

Smeds commented May 17, 2021

def CombineRegionInfo(listToCompress, regions):
from collections import OrderedDict
previous_region = []
current_region = []
combine_temp = []
newList=[]
index=-1 # Since we compare with the previous start at -1 instead of 0 to jump one step and start with the first element as a previous value
# Since we will save the previous value on the current line iteration we need one extra made up value in both lists to make sure the last elment is saved
regions.append('end.extra')
listToCompress.append(['end.extra'])
for line in regions:
current_region = line.split('.')
current_region = current_region[0]
if not(previous_region ==[]):
if previous_region == current_region:
combine_temp += listToCompress[index]
else:
combine_temp += listToCompress[index]
newList.append(combine_temp)
combine_temp = []
index+=1
previous_region=current_region
# Removes the added elements to the input lists
regions.pop()
listToCompress.pop()
return newList

Will this not combine regions wrongly, if input regions aren't sorted. And how does this function differ from CombineRegionInfo in CombineRows_generator.py

def CombineRegionInfo(listToCompress, regions):
	import re


	current_region = []
	combine_temp = {}
	newList=[]
	index=0 # Since we compare with the previous start at -1 instead of 0 to jump one step and start with the first element as a previous value


	for line in regions:
		current_region = re.split('\.|,|_',line)
		if (current_region[0] == 'iSNP' or current_region[0] == 'iIndel' or current_region[0] == 'MSI'):
			current_region[0] = "-".join([current_region[0],current_region[1],current_region[2]])
			current_region[1] = "-".join([current_region[0],current_region[1],current_region[2]])
			current_region[2] = "-".join([current_region[0],current_region[1],current_region[2]])
		current_region = current_region[0]


		if current_region in combine_temp.keys():
			combine_temp[current_region]=combine_temp[current_region]+listToCompress[index]


		else:
			combine_temp[current_region]=listToCompress[index]
		index+=1


	newList = [v for v in combine_temp.values()]
	# region_name = [k for k in combine_temp.keys()]


	return newList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant