J-Express forum
July 20, 2019, 04:06:31 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: J-Express 2011 released. Download from jexpress.bioinfo.no
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: clone a dataset, modify and put in tree  (Read 4205 times)
Bjarte Dysvik
Administrator
Full Member
*****
Posts: 117


View Profile Email
« on: September 30, 2005, 10:54:36 AM »

This script will clone a dataset and make a data-column be column+column[i+1]. It will also create new identifiers for the column data. It can be easily modified to let a column be for instance ratio of two column in a dataset compiled of [channel1][channel2][channel1][channel2] etc..



#description: Clone a dataset, modify and put in project tree

from java.lang import String

#The column in the identifiers having a concatenated string with calls
APMColumn = 2

inf = data.getInfos()
n=data.getDataLength()
m=data.getDataWidth()

   
a = data.clone()

a.setFile("extracted from python")
dat = data.getData()


newdata = []

for i in range(n):
   newline = []
   for j in range(m/2):
      newline=newline+[ dat[j*2]+dat[(2*j)+1] ]

   newdata = newdata+[newline]



a.removeFromParent()
main.addNode(a,data)
a.unLink(0)

a.setData(newdata)

newcolumnID = []
for j in range(m):
   newColumn =["column "+String.valueOf(j)]
   newcolumnID=newcolumnID+[newColumn]

print(newcolumnID)

a.setColInfos(newcolumnID)


a.setColInfoHeaders( ["New identifiers"] )



Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.14 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!