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

Ben lambda fix #120

Open
wants to merge 2 commits into
base: ben_lambda
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions awslambda/lambda/reg_gzip_md5_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def split_on_column(fh, folder, col=3):
pass
except FileExistsError:
pass

try:
flines = fh.readlines()
except AttributeError:
Expand All @@ -46,10 +46,10 @@ def split_on_column(fh, folder, col=3):
for t in fields[col].split('+'):
t = re.sub('/', '::', t)
peaks[t] = peaks.get(t,[])
peaks[t].append("\t".join(fields[0:col-1]+[t]+fields[col+1:])+"\n")
peaks[t].append("\t".join(fields[0:col]+[t]+fields[col+1:])+"\n")

return peaks

def gzip_md5_fh(fh, bucket, key):

gz_body = BytesIO()
Expand All @@ -61,7 +61,7 @@ def gzip_md5_fh(fh, bucket, key):
# it's a list of strings
for l in fh:
gz.write(l.encode('utf8'))

gz.close()
try:
put_res = s3.put_object(Bucket=bucket, Key=key+'.gz', Body=gz_body.getvalue())
Expand Down Expand Up @@ -111,7 +111,7 @@ def lambda_handler(event, context):
if split_column:
new_folder = os.path.basename(key).split('.')
old_folder = os.path.dirname(key)
new_folder = new_folder[0]
new_folder = new_folder[0] + '_PWM_split'
print("{} :: {}".format(old_folder, new_folder))
peaks = split_on_column(response['Body'], new_folder, col=split_column)
for target in peaks.keys():
Expand Down Expand Up @@ -140,4 +140,4 @@ def main():


if __name__ == '__main__':
main()
main()