Initial Release
This is my entry for the code-golf challenge of the Employee Programming Challenge #1. This template spins up InterSystems IRIS Community Edition in a docker container and contains the RunScript.mac.
The code is contained within a single line of python code, run from a single line of objectscript in the RunScript.Mac
d $SYSTEM.Python.Run("import csv,gzip,glob;s=lambda c:(v:=[y for x in c[1:-1].split(',')if x and(y:=float(x))==y])and(min(v),max(v))or(0,0);o=open('/o/r.csv','w');W=csv.writer(o).writerow;W('source_id bp_min_flux bp_max_flux rp_min_flux rp_max_flux percentage_change'.split());[[W([r['source_id'],a,b,c,d,p])for r in csv.DictReader(l for l in gz if l[0]!='#')for(a,b),(c,d)in[(s(r['bp_flux']),s(r['rp_flux']))]if(p:=max((b-a)/a*100 if a else-1,(d-c)/c*100 if c else-1))>100]or gz.close()for f in sorted(glob.glob('/i/*.gz'))[:20]for gz in[gzip.open(f,'rt')]];o.close()")
This line opens the .csv.gzip files, calculates the min flux, max flux and percentage change, and writes it to an output file, data/out/r.csv.
Note: I changed the docker-compose volume mounts to shorten the paths to the files. If this is deemed an edit against the “spirit” of the code-golf competition, I will happily change these paths from /i/ and /o/ to /home/irisowner/dev/data/in and /home/irisowner/dev/Data/out and accept the ~50 extra characters in my solution!
Make sure you have git and Docker desktop installed.
Clone and build the repository
git clone https://github.com/isc-ging/gaia-golf.git
cd gaia-golf
docker-compose up -d
and run:
docker-compose exec iris iris session iris
do ^RunScript