merge_machine/gridding.py
def fileToVariantMap(fileName, sep = '|', includeSelf = False):
	''' The input format is pipe-separated, column 1 is the main variant, column 2 an alternative variant.

		Returns a reverse index, namely a map from original alternative variant to original main variant

		Parameters:
		includeSelf if True, then the main variant will be included in the list of alternative variants
			(so as to enable partial matching simultaneously).
	'''
	otherToMain = defaultdict(list)
	mainToOther = defaultdict(list)
	for r in fileRowIterator(fileName, sep):
		if len(r) < 2: continue
		main, alts = r[0], r[1:]
		for alt in alts: otherToMain[alt].append(main)
		mainToOther[main].extend(alts)
	l = list([(other, next(iter(main))) for (other, main) in otherToMain.items() if len(main) < 2])
	if includeSelf: l = list([(main, main) for main in mainToOther.keys()]) + l
	return dict(l)
 The input format is pipe-separated, column 1 is the main variant, column 2 an alternative variant.

		Returns a reverse index, namely a map from original alternative variant to original main variant

		Parameters:
		includeSelf if True, then the main variant will be included in the list of alternative variants
			(so as to enable partial matching simultaneously).
	
The input format is pipe-separated, column 1 is the main variant, column 2 an alternative variant.
Returns a reverse index, namely a map from original alternative variant to original main variant

includeSelf if True, then the main variant will be included in the list of alternative variants
(so as to enable partial matching simultaneously).
The input format is pipe - separated column 1 is the main variant column 2 an alternative variant . Returns a reverse index namely a map from original alternative variant to original main variant includeSelf if True then the main variant will be included in the list of alternative variants ( so as to enable partial matching simultaneously ) .
def fileToVariantMap(fileName, sep = '|', includeSelf = False):
	otherToMain = defaultdict(list)
	mainToOther = defaultdict(list)
	for r in fileRowIterator(fileName, sep):
		if len(r) < 2: continue
		main, alts = r[0], r[1:]
		for alt in alts: otherToMain[alt].append(main)
		mainToOther[main].extend(alts)
	l = list([(other, next(iter(main))) for (other, main) in otherToMain.items() if len(main) < 2])
	if includeSelf: l = list([(main, main) for main in mainToOther.keys()]) + l
	return dict(l)
def fileToVariantMap ( fileName , sep = '|' , includeSelf = False ) : otherToMain = defaultdict ( list ) mainToOther = defaultdict ( list ) for r in fileRowIterator ( fileName , sep ) : if len ( r ) < 2 : continue main , alts = r [ 0 ] , r [ 1 : ] for alt in alts : otherToMain [ alt ] . append ( main ) mainToOther [ main ] . extend ( alts ) l = list ( [ ( other , next ( iter ( main ) ) ) for ( other , main ) in otherToMain . items ( ) if len ( main ) < 2 ] ) if includeSelf : l = list ( [ ( main , main ) for main in mainToOther . keys ( ) ] ) + l return dict ( l )
The input format is pipe-separated, column 1 is the main variant, column 2 an alternative variant.
The input format is pipe - separated column 1 is the main variant column 2 an alternative variant .
''' The input format is pipe-separated, column 1 is the main variant, column 2 an alternative variant.

		Returns a reverse index, namely a map from original alternative variant to original main variant

		Parameters:
		includeSelf if True, then the main variant will be included in the list of alternative variants
			(so as to enable partial matching simultaneously).
	'''
fileName
sep
includeSelf