Beispiel #1
0
def stringtofs(s):
	""" takes in string and tries to return Filesequence object, most of the heavylifting is done by the object itself. Input might be messy so 
		we have fallback to returning pure strings (single files not part of filesequence)
		This wrapper is needed because we support two string definitions. a simple string and mapped string in format seq1 -> seq2 """

	splitted_s = s.split(' -> ')
	if len(splitted_s) > 1:
		
		try:
			original = Filesequence.from_string(splitted_s[0])
		except ValueError:
			original = splitted_s[0]
		try:
			modified = Filesequence.from_string(splitted_s[1])
		except ValueError:
			modified = splitted_s[1]	
		return original, modified
	else:
		try:
			return None, Filesequence.from_string(s)
		except:
			return None, s
Beispiel #2
0
def single_seq(s, negative=False):
	""" takes in single string and tries to force it to one frame seq.
		This means that sequence has at least some digits
		Taking the ugly way out and using Filesequence object from_string constructor to figure out sequence formatting """

	splitted = split_alphanum(s, negative)

	matched = None
	modified = []

	for item in splitted[::-1]: # note reversed list
		if not matched and re.match('.*\d+', item): # item contains digits and can start with -
			matched = 1
			item = '[' + item + '-' + item + (len(item) * '@') + ']'
		modified.append(item) 

	modified.reverse()

	try:
		return [Filesequence.from_string(''.join(modified))]
	except:
		return None