<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" viewSourceURL="srcview/index.html" layout="absolute" height="100%" backgroundColor="#cccccc" backgroundAlpha="0" horizontalAlign="left" verticalGap="15" horizontalGap="15" initialize="getData( )" width="100%"> <mx:Script> <![CDATA[ import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.utils.ObjectUtil; [Bindable] private var experimentData:ArrayCollection=new ArrayCollection(); private var publications:Array=new Array(); private var cites:Array=new Array(); [Bindable] private var buckets:ArrayCollection=new ArrayCollection(); private var zbuckets:Array=new Array(); private function getData():void { trace("getData"); var params:Object=new Object(); params.gn='RV2429'; params.raw='2'; trace(ObjectUtil.toString(params)); dataResultService.send(params); trace("after calling the service"); } private function onRawResult(event:ResultEvent):void { var text:String=event.result.toString(); for each (var row:String in text.split(/\n/)) { var cells:Array=row.split(/\t/); if (cells.length > 4) { var exptsetid:int=parseInt(cells[6]); var exptid:int=parseInt(cells[0]); var fullSite:String; var pub:String=''; //var pub:String = '<a href="/cgi-bin/data/prd.pl?e='+exptid+'">'; if (publications[exptsetid]) { pub=pub + publications[exptsetid]; fullSite=cites[exptsetid]; } else { pub=pub + "Unpublished experiment set"; fullSite="View experiment set information for unpublished experiement set"; } //pub = pub + "</a>"; var zb:int=parseInt(cells[1]); experimentData.addItem({exptId: exptid, zbucket: zb, mbucket: parseInt(cells[2]), abucket: parseInt(cells[3]), exptName: cells[4], category: cells[5], cite: pub, fullCitation: fullSite, lograt: parseFloat(cells[7]), intense: parseFloat(cells[8]), z: parseFloat(cells[9])}); if (!zbuckets[zb]) { zbuckets[zb]=0; } zbuckets[zb]+=1; } else if (cells.length == 2) { var pattern:RegExp=/\).*$/i; var exptset:int=parseInt(cells[0]); var ps:String=cells[1]; cites[exptset]=ps; ps=ps.replace(/\).*$/, ")"); publications[exptset]=ps; } } // calculate the buckets for (var i:int=0; i < zbuckets.length; i++) { if (zbuckets[i]) { buckets.addItem({zscore: i, count: zbuckets[i]}); //trace(i,zbuckets[i]); } } trace("data loaded"); } private function faultHandler(event:FaultEvent):void { trace("badness" + event.fault.faultCode + " , " + event.fault.faultString); Alert.show(event.fault.faultCode + " , " + event.fault.faultString); } ]]> </mx:Script> <mx:HTTPService id="dataResultService" url="http://www.stanford.edu/~jhubble/sampledata.txt" resultFormat="text" result="onRawResult(event)" fault="faultHandler(event)"/> <mx:HBox> <mx:Panel resize="true" title="Histogram" layout="horizontal" color="0xffffff" borderAlpha="0.15" width="600" height="600" paddingTop="10" paddingRight="5" paddingBottom="10" paddingLeft="5" horizontalAlign="center"> <mx:ColumnChart id="bar" height="100%" width="100%" color="0x323232" columnWidthRatio=".97" showDataTips="true" dataProvider="{buckets}"> <mx:horizontalAxis> <mx:CategoryAxis categoryField="zscore"/> </mx:horizontalAxis> <mx:series> <mx:ColumnSeries yField="count" xField="zscore" displayName="Significance (Z-Score)"/> </mx:series> </mx:ColumnChart> </mx:Panel> <mx:Panel title="Experiments" layout="vertical" color="0xffffff" borderAlpha="0.15" minWidth="500" paddingTop="5" paddingRight="10" paddingBottom="10" paddingLeft="10" horizontalAlign="center"> <mx:Label width="100%" color="0x323232" text="Experiment List."/> <mx:DataGrid allowMultipleSelection="true" allowDragSelection="true" id="dg" color="0x323232" width="100%" rowCount="20" dataProvider="{experimentData}"> <mx:columns> <mx:DataGridColumn width="15"> <mx:itemRenderer> <mx:Component> <mx:CheckBox label=""/> </mx:Component> </mx:itemRenderer> </mx:DataGridColumn> <mx:DataGridColumn dataField="exptName" headerText="Experiment Name"/> <mx:DataGridColumn dataField="category" headerText="Category"/> <mx:DataGridColumn dataField="lograt" headerText="log ratio"/> <mx:DataGridColumn dataField="intense" headerText="intensity"/> <mx:DataGridColumn dataField="z" headerText="significance"/> <mx:DataGridColumn dataField="cite" textDecoration="underline" dataTipField="fullCitation" headerText="Publication" width="180" showDataTips="true"> </mx:DataGridColumn> </mx:columns> </mx:DataGrid> </mx:Panel> </mx:HBox> </mx:Application>
Friday, November 09, 2012
flex code
I am not sure what this was.... But its been sitting in my drafts for 3 years. Its some code in flex to handle some biological experiment data.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment