• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java CloseableRowIterator类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.knime.core.data.container.CloseableRowIterator的典型用法代码示例。如果您正苦于以下问题:Java CloseableRowIterator类的具体用法?Java CloseableRowIterator怎么用?Java CloseableRowIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

CloseableRowIterator类属于org.knime.core.data.container包,在下文中一共展示了CloseableRowIterator类的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: isPairRDD

点赞 3

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
/**
 * Check if table contain JavaPairRDD object. Only for RddTables. Other
 * tables will throw a ClassCastException.
 * 
 * @param table
 *            <code>BufferedDataTable</code>
 * @throws IndexOutOfBoundsException
 *             If <code>table</code> contains more than one cell
 * @throws ClassCastException
 *             If <code>table</code> isn't a RddTable
 * @return
 */
public static Boolean isPairRDD(BufferedDataTable table) {
	String[] names = table.getSpec().getColumnNames();
	if (names.length != 1) {
		throw new IndexOutOfBoundsException(
				"table should contain only one cells");
	}
	CloseableRowIterator it = table.iterator();
	DataRow firstRow = it.next();
	try {
		RddCell rddCell = (RddCell) firstRow.getCell(0);
		return false;
	} catch (ClassCastException e) {
		PairRddCell pairRddCell = (PairRddCell) firstRow.getCell(0);
		return true;
	}
}
 

开发者ID:pavloff-de,
项目名称:spark4knime,
代码行数:29,
代码来源:TableCellUtils.java

示例2: isRDDTable

点赞 3

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
/**
 * Check if table contains JavaRDDLike object
 * 
 * @param table
 *            <code>BufferedDataTable</code>
 * @return
 */
public static Boolean isRDDTable(BufferedDataTable table) {
	String[] names = table.getSpec().getColumnNames();
	if (names.length != 1) {
		// RDD table should contain just one column
		return false;
	}
	CloseableRowIterator it = table.iterator();
	DataRow firstRow = it.next();
	if (it.hasNext()) {
		// RDD table should contain just one row
		return false;
	}
	try {
		RddCell rddCell = (RddCell) firstRow.getCell(0);
		return true;
	} catch (Exception e) {
		try {
			PairRddCell pairRddCell = (PairRddCell) firstRow.getCell(0);
			return true;
		} catch (Exception ee) {
			return false;
		}
	}
}
 

开发者ID:pavloff-de,
项目名称:spark4knime,
代码行数:32,
代码来源:TableCellUtils.java

示例3: createRDD

点赞 3

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
/**
 * Creates JavaRDD from BufferedDataTable
 * 
 * @param data
 *            <code>BufferedDataTable</code> to parallelize
 * @param colIndices
 *            selected columns
 * @return <code>JavaRDD</code>
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
private JavaRDD createRDD(BufferedDataTable data, int[] colIndices) {
	// make a copy of data
	ArrayList copyOfData = new ArrayList(data.getRowCount());
	CloseableRowIterator rowIt = data.iterator();
	while (rowIt.hasNext()) {
		DataRow nextRow = rowIt.next();
		copyOfData.add(getCellValue(nextRow.getCell(colIndices[0])));
	}

	// create sparkContext and parallelize collection
	JavaSparkContext sparkContext = SparkContexter.getSparkContext(m_master
			.getStringValue());
	return sparkContext.parallelize(copyOfData);
}
 

开发者ID:pavloff-de,
项目名称:spark4knime,
代码行数:25,
代码来源:TableToRDDNodeModel.java

示例4: createPairRDD

点赞 3

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
/**
 * Creates JavaPairRDD from BufferedDataTable
 * 
 * @param data
 *            <code>BufferedDataTable</code> to parallelize
 * @param colIndices
 *            selected columns
 * @return <code>JavaPairRDD</code>
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
private JavaPairRDD createPairRDD(BufferedDataTable data, int[] colIndices) {
	// make a copy of data
	ArrayList copyOfData = new ArrayList(data.getRowCount());
	CloseableRowIterator rowIt = data.iterator();
	while (rowIt.hasNext()) {
		DataRow nextRow = rowIt.next();
		// Scala Tuple2 as key-value pair
		copyOfData.add(new Tuple2(getCellValue(nextRow
				.getCell(colIndices[0])), getCellValue(nextRow
				.getCell(colIndices[1]))));
	}
	
	// create sparkContext and parallelize collection
	JavaSparkContext sparkContext = SparkContexter.getSparkContext(m_master
			.getStringValue());
	return JavaPairRDD.fromJavaRDD(sparkContext.parallelize(copyOfData));
}
 

开发者ID:pavloff-de,
项目名称:spark4knime,
代码行数:28,
代码来源:TableToRDDNodeModel.java

示例5: loadTable

点赞 3

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
/**
 * Method to read a sequence database from a BufferedTable in SPMF format.
 */
public void loadTable(BufferedDataTable[] input, String colName) {
	String thisLine; // variable to read each line.


       // for each line (sequence) in the file until the end
       CloseableRowIterator data =  input[0].iterator();
       int  colPosition = input[0].getDataTableSpec().findColumnIndex(colName);
       for(int i = 0; i < input[0].getRowCount();i++){
   		thisLine = data.next().getCell(colPosition).toString();
           // if the line is  a comment, is  empty or is a
           // kind of metadata
           if (thisLine.isEmpty() == false
                   || thisLine.charAt(0) != '#' || thisLine.charAt(0) != '%'
                   || thisLine.charAt(0) != '@') {
           	addSequence(thisLine.split(" "));
           }
       }
}
 

开发者ID:DeOlSo,
项目名称:ADC2015_De,
代码行数:22,
代码来源:SequenceDatabase.java

示例6: loadFile

点赞 3

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
/**
 * Method to load a sequence database  in SPMF format.
 */
public void loadFile(final BufferedDataTable[] input,String colName) {

	
	String thisLine;
       // for each line (sequence) in the file until the end
       CloseableRowIterator data =  input[0].iterator();
       int  colPosition = input[0].getDataTableSpec().findColumnIndex(colName);
       for(int i = 0; i < input[0].getRowCount();i++){
   		thisLine = data.next().getCell(colPosition).toString();
           // if the line is  a comment, is  empty or is a
           // kind of metadata
           if (thisLine.isEmpty() == false &&
				thisLine.charAt(0) != '#' && thisLine.charAt(0) != '%'
				&& thisLine.charAt(0) != '@') {
           	 addSequence(thisLine.split(" "));
           }
       }
	
	
	
}
 

开发者ID:DeOlSo,
项目名称:ADC2015_De,
代码行数:25,
代码来源:SequenceDatabase.java

示例7: loadFile

点赞 3

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
/**
 * Method to load a sequence database in SPMF format.
 */
public void loadFile(final BufferedDataTable[] input,String colName) {

	
	String thisLine;
       // for each line (sequence) in the file until the end
       CloseableRowIterator data =  input[0].iterator();
       int  colPosition = input[0].getDataTableSpec().findColumnIndex(colName);
       for(int i = 0; i < input[0].getRowCount();i++){
   		thisLine = data.next().getCell(colPosition).toString();
           // if the line is  a comment, is  empty or is a
           // kind of metadata
           if (thisLine.isEmpty() == false &&
				thisLine.charAt(0) != '#' && thisLine.charAt(0) != '%'
				&& thisLine.charAt(0) != '@') {
           	 addSequence(thisLine.split(" "));
           }
       }
	
	
	
}
 

开发者ID:DeOlSo,
项目名称:ADC2015_De,
代码行数:25,
代码来源:SequenceDatabase.java

示例8: fillMap

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
Map<String, File> fillMap(BufferedDataTable inData) throws InvalidSettingsException
  	{
  	Map<String, File> sample2bam=new HashMap<String, File>();
  	int bamColumn=findColumnIndex(inData.getSpec(),m_bamColumn,StringCell.TYPE);
int sampleColumn=findColumnIndex(inData.getSpec(),m_sample2Column,StringCell.TYPE);
CloseableRowIterator iter=null;
try
	{
	iter=inData.iterator();
	while(iter.hasNext())
		{
		DataRow row=iter.next();
		String sample= getString(row, sampleColumn);
		String bam= getString(row, bamColumn);
		if(bam==null || bam.isEmpty()) continue;
		File bamFile=new File(bam);
		if(!bamFile.exists() ||
			!bamFile.isFile() || 
			!bamFile.canRead() ||
			!bamFile.getName().toLowerCase().endsWith(".bam"))
			{
			throw new IllegalArgumentException("bad file:"+bamFile);
			}
		sample2bam.put(sample, bamFile);
		}
	return sample2bam;
	}
finally
	{
	safeClose(iter);
	}
  	}
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:33,
代码来源:LocalBamNodeModel.java

示例9: execute

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
@Override
  protected BufferedDataTable[] execute(
  		final BufferedDataTable[] inData,
          final ExecutionContext exec
          ) throws Exception
      {
this.sample2bam.clear();

if(inData.length>1)
	{
	int bamColumn=findColumnIndex(inData[1].getSpec(),"bam",StringCell.TYPE);
	int sampleColumn=findColumnIndex(inData[1].getSpec(),"SAMPLE",StringCell.TYPE);
	CloseableRowIterator iter=null;
	try
		{
		iter=inData[1].iterator();
		while(iter.hasNext())
			{
			DataRow row=iter.next();
			String sample= getString(row, sampleColumn);
			String bam= getString(row, bamColumn);
			if(bam==null || bam.isEmpty()) continue;
			this.sample2bam.put(sample, bam);
			}
		}
	finally
		{
		if(iter!=null) iter.close();
		}
	}
setInternalTables(inData);
return new BufferedDataTable[0];
      }
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:34,
代码来源:BamViewNodeModel.java

示例10: safeClose

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
protected void safeClose(RowIterator iter)
{
if(iter==null) return;
if(iter instanceof CloseableRowIterator)
	{
	CloseableRowIterator.class.cast(iter).close();
	}
}
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:9,
代码来源:AbstractNodeModel.java

示例11: hiliteRows

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
private void hiliteRows(final ErrorCollector collector, final SingleNodeContainer node,
                        final TestflowConfiguration flowConfiguration) {
    for (int i = 0; i < node.getNrOutPorts(); i++) {
        if (node.getOutputObject(i) instanceof BufferedDataTable) {
            int max = flowConfiguration.getMaxHiliteRows();

            List<RowKey> keys = new ArrayList<RowKey>();
            CloseableRowIterator it = ((BufferedDataTable)node.getOutputObject(i)).iterator();
            while (it.hasNext() && max-- > 0) {
                keys.add(it.next().getKey());
            }
            it.close();

            HiLiteHandler handler = node.getOutputHiLiteHandler(i);
            // hilite all
            handler.fireHiLiteEvent(new HashSet<RowKey>(keys));
            // unhilite sonme
            handler.fireUnHiLiteEvent(new HashSet<RowKey>(keys.subList((int) (0.1 * keys.size()),
                                                                     (int) Math.ceil(0.6 * keys.size()))));
            // unhilite all
            handler.fireClearHiLiteEvent();
        }
    }
}
 

开发者ID:SiLeBAT,
项目名称:BfROpenLab,
代码行数:25,
代码来源:WorkflowHiliteTest.java

示例12: execute

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData,
        final ExecutionContext exec) throws Exception {

    // select sort strategy
    boolean[] sortAscending;
    switch (m_selectionStrategy) {
    case BIGGEST:
        sortAscending = new boolean[] { false };
        break;
    case SMALLEST:
        sortAscending = new boolean[] { true };
        break;
    default:
        throw new IllegalStateException(
                "No case defined for this ElementSelectionStrategy:"
                        + m_selectionStrategy.toString());
    }

    // Sort
    final List<String> columns =
            Arrays.asList(m_columnModel.getStringValue());

    final int index = inData[0].getSpec()
            .findColumnIndex(m_columnModel.getStringValue());

    final BufferedDataTableSorter sorter =
            new BufferedDataTableSorter(inData[0], columns, sortAscending);
    final BufferedDataTable sorted = sorter.sort(exec);

    exec.setMessage("Writing result table");
    final BufferedDataContainer container =
            exec.createDataContainer(inData[0].getDataTableSpec());
    final CloseableRowIterator iterator = sorted.iterator();

    int i = 0;
    while (i < m_numberOfElementsModel.getIntValue()) {
        try {
            final DataRow next = iterator.next();
            // skip rows with missing
            if (next.getCell(index).isMissing()) {
                LOGGER.warn("Encountered missing value, skipping row: "
                        + next.getKey());
                continue;
            } else {
                container.addRowToTable(next);
                i++;
            }
        } catch (final NoSuchElementException e) {
            LOGGER.warn("Not enough Elements in the input table to satisfy "
                    + "the number of elements setting.");
            break;
        }
    }
    container.close();

    // output the result as a BufferedDataTable[].
    return new BufferedDataTable[] { container.getTable() };
}
 

开发者ID:knime,
项目名称:knime-activelearning,
代码行数:63,
代码来源:ElementSelectorNodeModel.java

示例13: execute

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
@Override
protected BufferedDataTable[] execute(BufferedDataTable[] inData,
		ExecutionContext exec) throws Exception
	{
	BufferedDataContainer container1=null;
	try
    	{
        // the data table spec of the single output table, 
        // the table will have three columns:
		BufferedDataTable inTable=inData[0];
		DataTableSpec spec1=inTable.getDataTableSpec();
		DataTableSpec spec2=createDataSpec();
		
        container1 = exec.createDataContainer(
        		new DataTableSpec(spec1,
        		spec2
        		));
        float total=inTable.getRowCount();
        
        
        int nRow=0;
        int outIndex=0;
        CloseableRowIterator iter=null;
        try {
        	iter=inTable.iterator();
        	while(iter.hasNext())
        		{
        		DataRow row=iter.next();
        		++nRow;
        		
            	
            	List<DataCell[]> cells=scan(row,spec1);
            	if(cells!=null && !cells.isEmpty())
            		{
            		for(DataCell[] r2:cells)
            			{
            			outIndex++;
            			container1.addRowToTable(new AppendedColumnRow(RowKey.createRowKey(outIndex),row,r2));
            			}
            		}
            	else
            		{
            		DataCell empty[]=new DataCell[spec2.getNumColumns()];
            		for(int i=0;i< empty.length;++i) empty[i]=DataType.getMissingCell();
            		outIndex++;
           			container1.addRowToTable(new AppendedColumnRow(RowKey.createRowKey(outIndex),row,empty));
            		}
            	exec.checkCanceled();
            	exec.setProgress(nRow/total,"NCBI....");
        		}
			} 
        catch (Exception e)
			{
        	e.printStackTrace();
			throw e;
			}
		finally
			{
			safeClose(iter);
			}
        
		// once we are done, we close the container and return its table
        container1.close();
        BufferedDataTable out1 = container1.getTable();
        container1=null;
        BufferedDataTable array[]= new BufferedDataTable[]{out1};
    	return array;
    	}
catch(Exception err)
	{
	getLogger().error("Boum", err);
	err.printStackTrace();
	throw err;
	}
finally
	{
	if(container1!=null) container1.close();
	}
  }
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:80,
代码来源:AbstractNcbiEUtilsNodeModel.java

示例14: execute

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
@Override
protected BufferedDataTable[] execute(
	BufferedDataTable[] inData,
   	ExecutionContext exec
   	) throws Exception
   	{
   	if(inData==null || inData.length!=1)
     	{
     	throw new InvalidSettingsException("Expected one table.");
     	}
   	BufferedDataTable inTable=inData[0];
   	int nRows=0;
   	double total=inTable.getRowCount();
   	CloseableRowIterator iter=null;
   	
   	PrintWriter out=null;
   	try
    	{
   		out=new PrintWriter(m_filename.getStringValue());
   	
   		out.println("{| border='1'");
   		out.println("|+ <nowiki>title</nowiki>");
   		out.print("!");
   		for(int i=0;i< inTable.getDataTableSpec().getNumColumns();++i)
   			{
   			if(i!=0) out.print("!!");
   			out.print(inTable.getDataTableSpec().getColumnSpec(i).getName());
   			}
   		out.println();
   		
    	iter=inTable.iterator();
    	while(iter.hasNext())
    		{
    		++nRows;
    		DataRow row=iter.next();
    		
    		
    		out.println("|-");
   			out.print("|");
   			for(int i=0;i< row.getNumCells();++i)
   				{
   				if(i!=0) out.print("||");
   				out.print(String.valueOf(row.getCell(i).toString()));
   				}
   			out.println();
    		
    		exec.checkCanceled();
           	exec.setProgress(nRows/total,"Building wiki table");
    		}
    	
    	out.println("|}");
   		out.flush();
        return new BufferedDataTable[0];
    	}
   	catch (Exception e) {
		e.printStackTrace();
		throw e;
		}
   	finally
   		{
   		if(iter!=null) iter.close();
   		if( out!=null)  { out.flush(); out.close();}
   		}
   	}
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:65,
代码来源:MediaWikiExportNodeModel.java

示例15: execute

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
@Override
  protected BufferedDataTable[] execute(
  		final BufferedDataTable[] inData,
          final ExecutionContext exec
          ) throws Exception
          {
	BufferedDataContainer container1=null;
	BufferedDataContainer container2=null;
	try
    	{
        // the data table spec of the single output table, 
        // the table will have three columns:
		BufferedDataTable inTable=inData[0];
       
		DataTableSpec inDataTableSpec = inTable.getDataTableSpec();
		int qualColumn= inDataTableSpec.findColumnIndex("QUAL");
		if(qualColumn==-1) throw new IllegalArgumentException("Cannot find column \"QUAL\"");
		if(inDataTableSpec.getColumnSpec(qualColumn).getType()!=DoubleCell.TYPE)
    		{
    		throw new IllegalArgumentException("column \"QUAL\" is not a double");
    		}
        container1 = exec.createDataContainer(inDataTableSpec);
        container2 = exec.createDataContainer(inDataTableSpec);
        
        double total=inTable.getRowCount();
        int nRow=0;
        CloseableRowIterator iter=null;
        try {
        	iter=inTable.iterator();
        	while(iter.hasNext())
        		{
        		++nRow;
        		DataRow row=iter.next();
        		double qual=DoubleCell.class.cast(row.getCell(qualColumn)).getDoubleValue();

        		if(	qual>= m_minQual.getDoubleValue()
        			)
					{
					container1.addRowToTable(row);
					}
				else
					{
					container2.addRowToTable(row);
					}
        		exec.checkCanceled();
            	exec.setProgress(nRow/total,"Filtering....");
        		}
			} 
        catch (Exception e)
			{
			throw e;
			}
		finally
			{
			if(iter!=null) iter.close();
			}
        
		// once we are done, we close the container and return its table
        container1.close();
        BufferedDataTable out1 = container1.getTable();
        container1=null;
        
        container2.close();
        BufferedDataTable out2 = container2.getTable();
        container2=null;
        BufferedDataTable array[]= new BufferedDataTable[]{out1,out2};
    	return array;
    	}
catch(Exception err)
	{
	getLogger().error("Boum", err);
	err.printStackTrace();
	throw err;
	}
finally
	{
	if(container1!=null) container1.close();
	if(container2!=null) container2.close();
	}
     }
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:81,
代码来源:QualNodeModel.java

示例16: execute

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
@Override
  protected BufferedDataTable[] execute(
  		final BufferedDataTable[] inData,
          final ExecutionContext exec
          ) throws Exception
          {
	BufferedDataContainer container1=null;
	BufferedDataContainer container2=null;
	try
    	{
        // the data table spec of the single output table, 
        // the table will have three columns:
		BufferedDataTable inTable=inData[0];
       
		DataTableSpec inDataTableSpec = inTable.getDataTableSpec();
		int idColumn= inDataTableSpec.findColumnIndex("ID");
		if(idColumn==-1) throw new IllegalArgumentException("Cannot find column \"ID\"");
        container1 = exec.createDataContainer(inDataTableSpec);
        container2 = exec.createDataContainer(inDataTableSpec);
        
        double total=inTable.getRowCount();
        int nRow=0;
        CloseableRowIterator iter=null;
        try {
        	iter=inTable.iterator();
        	while(iter.hasNext())
        		{
        		++nRow;
        		DataRow row=iter.next();
        		String ID=StringCell.class.cast(row.getCell(idColumn)).getStringValue();
				
				
        		if(!(ID.isEmpty() || ID.equals(".")))
					{
					container1.addRowToTable(row);
					}
				else
					{
					container2.addRowToTable(row);
					}
        		}
        	exec.checkCanceled();
           	exec.setProgress(nRow/total,"Filtering....");
			} 
        catch (Exception e)
			{
			throw e;
			}
		finally
			{
			if(iter!=null) iter.close();
			}
        
		// once we are done, we close the container and return its table
        container1.close();
        BufferedDataTable out1 = container1.getTable();
        container1=null;
        
        container2.close();
        BufferedDataTable out2 = container2.getTable();
        container2=null;
        BufferedDataTable array[]= new BufferedDataTable[]{out1,out2};
    	return array;
    	}
catch(Exception err)
	{
	getLogger().error("Boum", err);
	err.printStackTrace();
	throw err;
	}
finally
	{
	if(container1!=null) container1.close();
	if(container2!=null) container2.close();
	}
     }
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:77,
代码来源:HavingIdNodeModel.java

示例17: execute

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
@Override
protected BufferedDataTable[] execute(
	BufferedDataTable[] inData,
   	ExecutionContext exec
   	) throws Exception
   	{
   	if(inData==null || inData.length!=1)
     	{
     	throw new InvalidSettingsException("Expected one table.");
     	}
   	BufferedDataTable inTable=inData[0];
   	int nRows=0;
   	double total=inTable.getRowCount();
   	CloseableRowIterator iter=null;
   	
   	DataTableSpec inSpecs=inData[0].getDataTableSpec();
   	int chromCol=findColumnIndex(inSpecs,m_chromCol,StringCell.TYPE);
       int posCol=findColumnIndex(inSpecs,m_posCol,IntCell.TYPE);
       int refCol=findColumnIndex(inSpecs,m_refCol,StringCell.TYPE);
       int altCol=findColumnIndex(inSpecs,m_altCol,StringCell.TYPE);
   	
   	PrintWriter out=null;
   	try
    	{
   		out=new PrintWriter(getFileOutSetting().getStringValue());
   		
    	iter=inTable.iterator();
    	while(iter.hasNext())
    		{
    		++nRows;
    		DataRow row=iter.next();
    		
    		if(!isATGC(getString(row, refCol))) continue;
    	
    		for(String alt: alts(getString(row, refCol),getString(row, altCol)))
    			{
    			if(!isATGC(alt)) continue;
    			write(out,
    					getString(row, chromCol),
    					getInt(row,posCol),
    					getString(row, refCol),
    					alt
    					);
    			}
    		
    		exec.checkCanceled();
           	exec.setProgress(nRows/total);
    		}

        return new BufferedDataTable[0];
    	}
   	catch (Exception e) {
		e.printStackTrace();
		throw e;
		}
   	finally
   		{
   		safeClose(iter);
   		if( out!=null)  { out.flush(); out.close();}
   		}
   	}
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:62,
代码来源:AbstractPredictionOutNodeModel.java

示例18: run

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
@Override
public void run()
	{
	for(;;)
		{
		DataRow row=null;
		
		synchronized (BasicPredictionNodeModel.this)
			{
			CloseableRowIterator iter=BasicPredictionNodeModel.this.iterator;
			if(iter==null || !iter.hasNext()) return;

			row=iter.next();
			}
		
		if(row==null)
			{
			return;
			}
		String chrom= StringCell.class.cast(row.getCell(columns.chromCol)).getStringValue();
		
		int position0=	IntCell.class.cast(row.getCell(columns.posCol)).getIntValue()-1;
		String ref= StringCell.class.cast(row.getCell(columns.refCol)).getStringValue();
		String alt= StringCell.class.cast(row.getCell(columns.altCol)).getStringValue();
		boolean ok;
		try
			{
			ok=accept(chrom,position0,ref,alt);
			}
		catch (Exception e)
			{
			e.printStackTrace();
			throw new RuntimeException(e);
			}
		synchronized (BasicPredictionNodeModel.this)
			{
			BufferedDataContainer container=(ok?
					BasicPredictionNodeModel.this.container1:
					BasicPredictionNodeModel.this.container2
					);
			if(container==null)
				{
				return;
				}
			container.addRowToTable(row);
			++numberOfRowsProcessed;
			}
		}
	}
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:50,
代码来源:BasicPredictionNodeModel.java

示例19: execute

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
@Override
  protected BufferedDataTable[] execute(
  		final BufferedDataTable[] inData,
          final ExecutionContext exec
          ) throws Exception
          {
	BufferedDataContainer container1=null;

	try
    	{
        // the data table spec of the single output table, 
        // the table will have three columns:
		BufferedDataTable inTable=inData[0];
       
		DataTableSpec inDataTableSpec = inTable.getDataTableSpec();
		int cqColumn=findColumnIndex(inDataTableSpec, m_cqCol,StringCell.TYPE);
		
        container1 = exec.createDataContainer(inDataTableSpec);
       
        
        Set<String> predictions=new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
        predictions.addAll(Arrays.asList(selected_gc.getStringArrayValue()));
        
     
        Pattern comma=Pattern.compile("[,]");
        double total=inTable.getRowCount();
        int nRow=0;
        CloseableRowIterator iter=null;
        try {
        	iter=inTable.iterator();
        	while(iter.hasNext())
        		{
        		++nRow;
        		DataRow row=iter.next();
        	
        		if(!row.getCell(cqColumn).isMissing())
	        		{
	        		String content=StringCell.class.cast(row.getCell(cqColumn)).getStringValue();
					
					for(String s:comma.split(content))
						{
						if(predictions.contains(s))
							{
							container1.addRowToTable(row);
							break;
							}
						}
	        		}
				
        		}
        	exec.checkCanceled();
           	exec.setProgress(nRow/total,"Filtering....");
			} 
        catch (Exception e)
			{
        	e.printStackTrace();
			throw e;
			}
		finally
			{
			safeClose(iter);
			}
        
		// once we are done, we close the container and return its table
        safeClose(container1);
        BufferedDataTable out1 = container1.getTable();
        container1=null;
       
        BufferedDataTable array[]= new BufferedDataTable[]{out1};
    	return array;
    	}
catch(Exception err)
	{
	err.printStackTrace();
	throw err;
	}
finally
	{
	safeClose(container1);
	}
     }
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:82,
代码来源:EnsemblGCNodeModel.java

示例20: execute

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
@Override
  protected BufferedDataTable[] execute(
  		final BufferedDataTable[] inData,
          final ExecutionContext exec
          ) throws Exception
          {
	BufferedDataContainer container1=null;
	BufferedDataContainer container2=null;
	try
    	{
        // the data table spec of the single output table, 
        // the table will have three columns:
		BufferedDataTable inTable=inData[0];
		RowComparator rowComparator=new RowComparator();
		@SuppressWarnings("unused")
		SortedTable sortedTable=new SortedTable(inData[2], rowComparator, false, exec);
		
		DataTableSpec inDataTableSpec = inTable.getDataTableSpec();
		
        container1 = exec.createDataContainer(inDataTableSpec);
        container2 = exec.createDataContainer(inDataTableSpec);
        
        
        
        
        double total=inTable.getRowCount();
        int nRow=0;
        CloseableRowIterator iter=null;
        try {
        	iter=inTable.iterator();
        	while(iter.hasNext())
        		{
        		++nRow;
        		DataRow row=iter.next();
        		
				container1.addRowToTable(row);
					
        		}
        	exec.checkCanceled();
           	exec.setProgress(nRow/total,"Filtering....");
			} 
        catch (Exception e)
			{
			throw e;
			}
		finally
			{
			if(iter!=null) iter.close();
			}
        
		// once we are done, we close the container and return its table
        container1.close();
        BufferedDataTable out1 = container1.getTable();
        container1=null;
        
        container2.close();
        BufferedDataTable out2 = container2.getTable();
        container2=null;
        BufferedDataTable array[]= new BufferedDataTable[]{out1,out2};
    	return array;
    	}
catch(Exception err)
	{
	getLogger().error("Boum", err);
	err.printStackTrace();
	throw err;
	}
finally
	{
	if(container1!=null) container1.close();
	if(container2!=null) container2.close();
	}
     }
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:74,
代码来源:RegionNodeModel.java

示例21: execute

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
@Override
  protected BufferedDataTable[] execute(
  		final BufferedDataTable[] inData,
          final ExecutionContext exec
          ) throws Exception
          {
	BufferedDataContainer container1=null;
	BufferedDataTable inTable=inData[0];
	int chromCol=findColumnIndex(inTable.getDataTableSpec(),m_chromColumn,StringCell.TYPE);
   	int posCol=findColumnIndex(inTable.getDataTableSpec(),m_posColumn,IntCell.TYPE);
	
	String selChrom=this.m_selectChrom.getStringValue();
	int chromStart= this.m_selectChromStart.getIntValue();
	int chromEnd= this.m_selectChromEnd.getIntValue();
	
	try
    	{
	
        container1 = exec.createDataContainer(inTable.getDataTableSpec());
       
        
        double total=inTable.getRowCount();
        int nRow=0;
        CloseableRowIterator iter=null;
        try {
        	iter=inTable.iterator();
        	while(iter.hasNext())
        		{
        		++nRow;
        		DataRow row=iter.next();
        		DataCell cell=row.getCell(chromCol);
        		if(cell.isMissing()) continue;
        		String chrom=StringCell.class.cast(cell).getStringValue();
        		
        		cell=row.getCell(posCol);
        		if(cell.isMissing()) continue;
        		int pos=IntCell.class.cast(cell).getIntValue();
        		
        		if((chrom.equals(selChrom) && chromStart<=pos && chromEnd>=pos) == !m_invert.getBooleanValue() )
        			{
        			container1.addRowToTable(row);
        			}
        		
        		exec.checkCanceled();
            	exec.setProgress(nRow/total,"Cut Region...");
        		}
			} 
        catch (Exception e)
			{
			throw e;
			}
		finally
			{
			if(iter!=null) iter.close();
			}
        
		// once we are done, we close the container and return its table
		safeClose(container1);
        BufferedDataTable out1 = container1.getTable();
        container1=null;
        
       
        BufferedDataTable array[]= new BufferedDataTable[]{out1};
    	return array;
    	}
catch(Exception err)
	{
	getLogger().error("Boum", err);
	err.printStackTrace();
	throw err;
	}
finally
	{
	safeClose(container1);
	}
     }
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:77,
代码来源:CutRegionNodeModel.java

示例22: execute

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
/**
   * {@inheritDoc}
   */
  @Override
  protected BufferedDataTable[] execute(
  		final BufferedDataTable[] inData,
          final ExecutionContext exec
          ) throws Exception
          {
	BufferedDataContainer container1=null;
	BufferedDataContainer container2=null;
	try
    	{
        // the data table spec of the single output table, 
        // the table will have three columns:
		BufferedDataTable inTable=inData[0];
        DataTableSpec inDataTableSpec = inTable.getDataTableSpec();
        MutationColumns vcfColumns= getMutationColumns(inData[0].getDataTableSpec());
        container1 = exec.createDataContainer(inDataTableSpec);
        container2 = exec.createDataContainer(inDataTableSpec);
        
        
        double total=inTable.getRowCount();
        int nRow=0;
        CloseableRowIterator iter=null;
        try {
        	iter=inTable.iterator();
        	while(iter.hasNext())
        		{
        		++nRow;
        		DataRow row=iter.next();
				if(accept(vcfColumns, row))
					{
					container1.addRowToTable(row);
					}
				else
					{
					container2.addRowToTable(row);
					}
        		}
        	exec.checkCanceled();
           	exec.setProgress(nRow/total,"Filtering....");
			} 
        catch (Exception e)
			{
			throw e;
			}
		finally
			{
			if(iter!=null) iter.close();
			}
        
		// once we are done, we close the container and return its table
        container1.close();
        BufferedDataTable out1 = container1.getTable();
        container1=null;
        
        container2.close();
        BufferedDataTable out2 = container2.getTable();
        container2=null;
        BufferedDataTable array[]= new BufferedDataTable[]{out1,out2};
    	getLogger().info("returning an array "+array.length);
    	return array;
    	}
catch(Exception err)
	{
	getLogger().error("Boum", err);
	err.printStackTrace();
	throw err;
	}
finally
	{
	if(container1!=null) container1.close();
	if(container2!=null) container2.close();
	}
     }
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:77,
代码来源:AbstractVCFFilterNodeModel.java

示例23: execute

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
@Override
protected BufferedDataTable[] execute(BufferedDataTable[] inData,
		ExecutionContext exec) throws Exception
	{
	
	Pattern comma=Pattern.compile("[,]");
	BufferedDataTable inTable=inData[0];
	DataTableSpec inSpecs=inTable.getDataTableSpec();
	CloseableRowIterator iter=null;
	
	int altColumn = inSpecs.findColumnIndex(this.m_altColumn.getStringValue());

	int rowIndex=0;
	double total= inTable.getRowCount();
	BufferedDataContainer container=exec.createDataContainer(createTableSpec(inSpecs,altColumn));
	try
		{
		iter=inTable.iterator();
		int nRow=0;
		while(iter.hasNext())
			{
			DataRow row=iter.next();
			nRow++;
			DataCell cell=row.getCell(altColumn);
			
			List<DataCell> cells=new ArrayList<DataCell>(row.getNumCells()+1);
			for(int i=0;i< row.getNumCells();++i)
				{
				cells.add(row.getCell(i));
				}
			cells.add(row.getCell(altColumn));//append src
			
			if(cell.isMissing() || StringCell.class.cast(cell).getStringValue().trim().length()==0)
				{
				container.addRowToTable(new DefaultRow(RowKey.createRowKey(++rowIndex), cells));
				}
			else
				{
				String alts=StringCell.class.cast(cell).getStringValue();
				for(String alt:comma.split(alts))
					{
					List<DataCell> cells2=new ArrayList<DataCell>(cells);
					cells2.set(altColumn, new StringCell(alt));
					container.addRowToTable(new DefaultRow(RowKey.createRowKey(++rowIndex), cells2));
					}
				}
            exec.checkCanceled();
            exec.setProgress(nRow/total,"Processing ALTS to ALT");
			}
		}
	catch(Exception err)
		{
		err.printStackTrace();
		throw err;
		}
	finally
		{
		safeClose(iter);
		}
	safeClose(container);
	BufferedDataTable out = container.getTable();
       container=null;
       return new BufferedDataTable[]{out};
	}
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:65,
代码来源:AltsToAltNodeModel.java

示例24: execute

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
@Override
   protected BufferedDataTable[] execute(
   		final BufferedDataTable[] inData,
           final ExecutionContext exec
           ) throws Exception
           {
	BufferedDataContainer container1=null;
	try
    	{
        // the data table spec of the single output table, 
        // the table will have three columns:
		BufferedDataTable inTable=inData[0];
        container1 = exec.createDataContainer(inTable.getDataTableSpec());
        int total=this.m_rowCount.getIntValue();
        

        int nRow=0;
        CloseableRowIterator iter=null;
        try {
        	iter=inTable.iterator();
        	while(iter.hasNext())
        		{
        		if(nRow>=total) break;
        		++nRow;
        		container1.addRowToTable(iter.next());
        		
        		//
        		exec.checkCanceled();
            	exec.setProgress(nRow+1/total,"Head....");
        		}
        	
			} 
        catch (Exception e)
			{
        	e.printStackTrace();
			throw e;
			}
		finally
			{
			if(iter!=null) iter.close();
			}
        
		// once we are done, we close the container and return its table
        container1.close();
        BufferedDataTable out1 = container1.getTable();
        container1=null;
        BufferedDataTable array[]= new BufferedDataTable[]{out1};
    	return array;
    	}
catch(Exception err)
	{
	getLogger().error("Boum", err);
	err.printStackTrace();
	throw err;
	}
finally
	{
	if(container1!=null) container1.close();
	}
  }
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:61,
代码来源:HeadNodeModel.java

示例25: execute

点赞 2

import org.knime.core.data.container.CloseableRowIterator; //导入依赖的package包/类
@Override
   protected BufferedDataTable[] execute(
   		final BufferedDataTable[] inData,
           final ExecutionContext exec
           ) throws Exception
           {
	BufferedDataContainer container1=null;
	
	try
    	{
        // the data table spec of the single output table, 
        // the table will have three columns:
		BufferedDataTable inTable=inData[0];
        container1 = exec.createDataContainer(inTable.getDataTableSpec());
        int total=inTable.getRowCount();
        
        
        int nRow=0;
      
        CloseableRowIterator iter=null;
        try {
        	iter=inTable.iterator();
        	while(iter.hasNext())
        		{
        		DataRow r=iter.next();
        		++nRow;
        		exec.checkCanceled();
            	exec.setProgress(nRow/(float)total,"Tail....");
            	
        		if(nRow+this.m_rowCount.getIntValue() <= total)
        			{
        			continue;
        			}
        		//
        		container1.addRowToTable(r);
        		}
			} 
        catch (Exception e)
			{
        	e.printStackTrace();
			throw e;
			}
		finally
			{
			safeClose(iter);
			}
        
		// once we are done, we close the container and return its table
        container1.close();
        BufferedDataTable out1 = container1.getTable();
        container1=null;
        BufferedDataTable array[]= new BufferedDataTable[]{out1};
    	return array;
    	}
catch(Exception err)
	{
	getLogger().error("Boum", err);
	err.printStackTrace();
	throw err;
	}
finally
	{
	if(container1!=null) container1.close();
	}
  }
 

开发者ID:lindenb,
项目名称:knime4bio,
代码行数:66,
代码来源:TailNodeModel.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)