本文整理汇总了Java中org.cytoscape.model.CyTable.createColumn方法的典型用法代码示例。如果您正苦于以下问题:Java CyTable.createColumn方法的具体用法?Java CyTable.createColumn怎么用?Java CyTable.createColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.cytoscape.model.CyTable
的用法示例。
在下文中一共展示了CyTable.createColumn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkSafeColumns
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
public static void checkSafeColumns(CyTable table) {
CyColumn column = table.getColumn(StyleFactory.HIGHLIGHT_COLUMN);
if (column == null) {
table.createColumn(StyleFactory.HIGHLIGHT_COLUMN, Double.class, false, 0D);
}
column = table.getColumn(StyleFactory.COLOR_COLUMN);
if (column == null) {
table.createColumn(StyleFactory.COLOR_COLUMN, String.class, false, null);
}
column = table.getColumn(StyleFactory.BRIGHTNESSS_COLUMN);
if (column == null) {
table.createColumn(StyleFactory.BRIGHTNESSS_COLUMN, Double.class, false, 0D);
}
}
示例2: set
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
public static void set(CyNetwork network, CyIdentifiable entry, String tableName, String name, Object value, Class<?> type) {
CyRow row = network.getRow(entry, tableName);
CyTable table = row.getTable();
CyColumn column = table.getColumn(name);
if (value != null) {
if (column == null) {
if (value instanceof List) {
table.createListColumn(name, type, false);
}
else if (value instanceof Collection) {
throw new IllegalArgumentException("Arrt. values collection is not a List: "
+ value.getClass().getSimpleName());
}
else {
table.createColumn(name, type, false);
}
}
row.set(name, value);
}
}
示例3: setEdgeAttribute
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
@Override
protected void setEdgeAttribute(CyEdge edge, String colName, Object value)
{
if (value == null) return; //ignore
if (value instanceof RdfNode) { value = value.toString(); }
CyTable table = myNet.getDefaultEdgeTable();
if (table.getColumn(colName) == null)
{
table.createColumn(colName, value.getClass(), true);
}
try
{
table.getRow(edge.getSUID()).set(colName, value);
}
catch (IllegalStateException e)
{
// class cast problem when sparql result does not match column class.
// TODO...
e.printStackTrace();
}
}
示例4: addProperties
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
public static void addProperties(Long suid, CyTable table,Map<String,Object> props){
for(Entry<String,Object> obj : props.entrySet()){
if(table.getColumn(obj.getKey()) == null){
if(obj.getValue().getClass() == ArrayList.class){
table.createListColumn(obj.getKey(), CyUtils.getArrayListType((ArrayList)obj.getValue()), false);
} else {
table.createColumn(obj.getKey(), obj.getValue().getClass(), false);
}
}
CyUtils.addValueToTable(suid,obj.getKey(),obj.getValue(),table);
}
}
示例5: set
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
public static void set(CyNetwork network, CyIdentifiable entry, String tableName, String name, Object value, Class<?> type) {
CyRow row = network.getRow(entry, tableName);
CyTable table = row.getTable();
CyColumn column = table.getColumn(name);
if (value != null) {
if (column == null) {
if (value instanceof List) {
table.createListColumn(name, type, false);
}
else if (value instanceof Collection) {
throw new IllegalArgumentException("Attribute value is a Collection and not List: "
+ value.getClass().getSimpleName());
}
else {
table.createColumn(name, type, false);
}
}
row.set(name, value);
}
}
示例6: checkColumn
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
private void checkColumn(CyTable table,
String name,
Class<?> type) {
CyColumn column = table.getColumn(name);
if (column == null) {
table.createColumn(name, type, false);
}
}
示例7: aggregateAttributes
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
private void aggregateAttributes(CyNetwork originNetwork, SummaryNetwork summaryNetwork) {
CyTable originNodeTable = originNetwork.getDefaultNodeTable();
CyTable summaryNodeTable = summaryNetwork.network.getDefaultNodeTable();
summaryNodeTable.createColumn("cluster node count", Integer.class, false);
List<String> columnsToAggregate = new ArrayList<>();
for(CyColumn column : originNodeTable.getColumns()) {
String name = column.getName();
if(summaryNodeTable.getColumn(name) == null) {
columnsToAggregate.add(name);
Class<?> listElementType = column.getListElementType();
if(listElementType == null) {
summaryNodeTable.createColumn(name, column.getType(), false);
}
else {
summaryNodeTable.createListColumn(name, listElementType, false);
}
}
}
for(SummaryCluster cluster : summaryNetwork.getClusters()) {
CyNode summaryNode = summaryNetwork.getNodeFor(cluster);
CyRow row = summaryNodeTable.getRow(summaryNode.getSUID());
row.set("name", cluster.getLabel());
row.set("cluster node count", cluster.getNodes().size());
for(String columnName : columnsToAggregate) {
Object result = aggregate(originNetwork, cluster, columnName);
row.set(columnName, result);
}
}
}
示例8: createNodeAttributeIfNotExists
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
private void createNodeAttributeIfNotExists(String colName)
{
CyTable table = myNet.getDefaultNodeTable();
if (table.getColumn(colName) == null)
{
table.createColumn(colName, String.class, true);
}
}
示例9: addEdgeInfo
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
private void addEdgeInfo(Graph<GeneInput> gfdNetNetwork) {
CyTable edgeTable = network.getDefaultEdgeTable();
try {
edgeTable.createColumn(DissimilairtyColumn, Double.class, false);
} catch (IllegalArgumentException ex) {
// Do nothing and just override the values in the collumn
}
List<CyEdge> edges = network.getEdgeList();
int noNodes = gfdNetNetwork.getNodes().size();
List<Object[]> relationshipList = new ArrayList<Object[]>();
for (int i = 0; i < noNodes; i++) {
String n1 = gfdNetNetwork.getNode(i).getName();
for (int j = i + 1; j < noNodes; j++) {
String n2 = gfdNetNetwork.getNode(j).getName();
Double weight = gfdNetNetwork.getEdgeWeight(i, j);
if (weight != -1) {
for(CyEdge edge : edges) {
String sourceName = network.getRow(edge.getSource()).get(CyNetwork.NAME, String.class);
String targetName = network.getRow(edge.getTarget()).get(CyNetwork.NAME, String.class);
if((sourceName.equalsIgnoreCase(n1) && targetName.equalsIgnoreCase(n2)) ||
(sourceName.equalsIgnoreCase(n2) && targetName.equalsIgnoreCase(n1))) {
edgeTable.getRow(edge.getSUID()).set(DissimilairtyColumn, weight);
Object[] row = new Object[3];
row[0] = sourceName;
row[1] = targetName;
row[2] = weight;
relationshipList.add(row);
break;
}
}
}
}
edgeRows = relationshipList.toArray(new Object[relationshipList.size()][3]);
}
}
示例10: addCount
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
/**
* Add the specified count in the specified column name to the specified node.
*
* @param node node
* @param network network
* @param columnName column name
* @param count count
*/
static void addCount(final CyNode node, final CyNetwork network, final String columnName, final int count)
{
CyTable table = network.getDefaultNodeTable();
CyRow row = table.getRow(node.getSUID());
if (table.getColumn(columnName) == null)
{
table.createColumn(columnName, Integer.class, false);
}
// todo: or add to current value
row.set(columnName, count);
}
示例11: detectImmutableProblem
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
private static String detectImmutableProblem(String key, CyTable table, Class<?> valueClass, Class<?> colClass){
CyColumn col = table.getColumn(key);
String newKey = key; // trying to make this less confusing with the extra variables
if(col.isImmutable() && !matchingValues(valueClass,colClass)){
newKey = key + "_cannot_change_original";
// we had this problem before and fixed it, now use the fixed column instead of the previous one!
if(table.getColumn(newKey) == null){
if(table.getColumn(key).getListElementType() != null){
table.createListColumn(newKey,table.getColumn(key).getListElementType() , false);
} else {
table.createColumn(newKey, table.getColumn(key).getType(), false);
}
// populate the new column!
List<CyRow> rows = table.getAllRows();
for(CyRow row : rows){
if(row.isSet(key)){
table.getRow(row.get("SUID", Long.class)).set(newKey, row.getRaw(key));
}
}
}
}
return newKey;
}
示例12: addValue
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
private void addValue(CyNode n, CyTable defNodeTab, String key, Object value) {
if(defNodeTab.getColumn(key) == null){
defNodeTab.createColumn(key, value.getClass(), false);
}
Object val2 = value;
CyColumn col = defNodeTab.getColumn(key);
if(!value.getClass().equals(col.getType())){
val2 = col.getType().cast(value);
}
defNodeTab.getRow(n.getSUID()).set(key, val2);
}
示例13: run
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
@Override
public void run(TaskMonitor tm) throws Exception {
CyNetwork network = targetNetwork.getSelectedValue();
CyTable targetTable = mappingManager.getMappingTable(network, targetClass.getSelectedValue().getTargetClass());
//Create the actual mapping
CyColumn mappingColumn = null;
if(createNewColumn)
{
targetTable.createColumn(newColumnName, DataSeriesMappingManager.MAPPING_COLUMN_CLASS, false);
mappingColumn = targetTable.getColumn(newColumnName);
}
else
{
mappingColumn = targetTable.getColumn(existingColumnForMapping.getSelectedValue());
}
if(mappingColumn == null)
{
throw new DataSeriesException("Could not get/create the column for mapping");
}
if(!mappingColumn.getType().equals(DataSeriesMappingManager.MAPPING_COLUMN_CLASS))
{
throw new DataSeriesException("The mapping column is of wrong type (should be " + DataSeriesMappingManager.MAPPING_COLUMN_CLASS.getSimpleName() + ", is" + mappingColumn.getType().getSimpleName() + ")");
}
mappingManager.mapDataSeriesRowsToTableColumn(targetNetwork.getSelectedValue(), targetClass.getSelectedValue().targetClass, mappingColumn.getName(), dataSeries.getSelectedValue());
//Fill the mapping column
if(mapByRowNames)
{
CyColumn rowNamesColumn = targetTable.getColumn(mapRowNamesWithColumn.getSelectedValue());
if(rowNamesColumn == null || !rowNamesColumn.getType().equals(String.class))
{
throw new DataSeriesException("The column for row names matches (" + mapRowNamesWithColumn.getSelectedValue() + ") has to exist and be of type string.");
}
int mapped = 0;
int notMapped = 0;
int empty = 0;
for(CyRow row : targetTable.getAllRows())
{
String rowNameInData = row.get(mapRowNamesWithColumn.getSelectedValue(), String.class);
if(rowNameInData == null || rowNameInData.isEmpty())
{
row.set(mappingColumn.getName(), null);
empty++;
}
else
{
List<String> rowNames = dataSeries.getSelectedValue().getRowNames();
int rowIndex = rowNames.indexOf(rowNameInData);
if(rowIndex < 0)
{
row.set(mappingColumn.getName(), null);
notMapped++;
}
else
{
int rowID = dataSeries.getSelectedValue().getRowID(rowIndex);
if (rowNames.lastIndexOf(rowNameInData) != rowIndex)
{
userLogger.warn("The data series '" + dataSeries.getSelectedValue().getName() + "' contains multiple rows with name '" + rowNameInData + "'. Mapping the node '" + rowNameInData + "' to row ID " + rowID);
}
row.set(mappingColumn.getName(), rowID);
mapped++;
}
}
}
userLogger.info("Mapped " + mapped + " rows to data series " + dataSeries.getSelectedValue().getName() + ", " + notMapped + " rows could not be mapped, " + empty + " rows were empty.");
}
}
示例14: createColumn
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
private static void createColumn(CyTable table, String name, Class<?> type) {
if(table.getColumn(name) == null)
table.createColumn(name, type, true);
}
示例15: copyColumn
import org.cytoscape.model.CyTable; //导入方法依赖的package包/类
private void copyColumn(CyColumn col, CyTable subTable) {
if (List.class.isAssignableFrom(col.getType()))
subTable.createListColumn(col.getName(), col.getListElementType(), false);
else
subTable.createColumn(col.getName(), col.getType(), false);
}