小编Eri*_* C.的帖子

使用regexp选择R dataframe中的行

我正在尝试在数据框中选择行,其中列中包含的字符串与正则表达式或子字符串匹配:

数据帧:

aName   bName   pName   call  alleles   logRatio    strength
AX-11086564 F08_ADN103  2011-02-10_R10  AB  CG  0.363371    10.184215
AX-11086564 A01_CD1919  2011-02-24_R11  BB  GG  -1.352707   9.54909
AX-11086564 B05_CD2920  2011-01-27_R6   AB  CG  -0.183802   9.766334
AX-11086564 D04_CD5950  2011-02-09_R9   AB  CG  0.162586    10.165051
AX-11086564 D07_CD6025  2011-02-10_R10  AB  CG  -0.397097   9.940238
AX-11086564 B05_CD3630  2011-02-02_R7   AA  CC  2.349906    9.153076
AX-11086564 D04_ADN103  2011-02-10_R2   BB  GG  -1.898088   9.872966
AX-11086564 A01_CD2588  2011-01-27_R5   BB  GG  -1.208094   9.239801
Run Code Online (Sandbox Code Playgroud)

例如,我想要一个只包含ADN在列中包含的行的数据帧bName.其次,我想包含所有行ADN的列bName和匹配2011-02-10_R2pName.

我尝试使用功能grep() …

regex r dataframe

24
推荐指数
2
解决办法
3万
查看次数

java线程等待死进程完成

我编写了一个java类来执行多线程任务,每个任务都运行一个外部进程.该过程负责将".chp"文件转换为".txt"文件.它用C语写.

这个过程在某个时刻中断,因为当我在终端中查看"顶部"时它会消失(可能是由于chp文件损坏).问题是我的java线程中的进程没有返回."process.waitFor()"似乎永远持续下去(至少是我为ExecutorService指定的12小时).

我做错了什么(没有捕捉异常?)?我尝试在MyThread中设置一个String类型的类变量,并输入一个错误消息代替抛出一个新的RuntimeException,然后在main的末尾打印String,但是线程代码没有达到这一点.它仍然停留在waitFor().

一旦C程序失败,进程是否应该终止?

程序在终端上打印(cf:MyThread):

A
B
C
Run Code Online (Sandbox Code Playgroud)

主要:

String pathToBin = "/path/to/bin";
List<MyThread> threadList = new ArrayList<MyThread>();

for (File f : folderList) {
    File[] chpFilesInFolder = f.listFiles(new FilenameFilter() {

        @Override
        public boolean accept(File dir, String name) {
            if (name.endsWith(".chp")){
                 return true;
            }else{
                 return false;
            }
        }
    });
    File chpFile = writeChpFiles(chpFilesInFolder);
    String[] cmd = {pathToBin, "--arg1", chpFile, "--out-dir", outputFolder};
    MyThread t = new MyThread(cmd, f, chpFilesInFolder);
    threadList.add(t);
}

ExecutorService threadExecutor = Executors.newFixedThreadPool(4);
for(MyThread th : threadList){
    threadExecutor.execute(th);
}
threadExecutor.shutdown(); …
Run Code Online (Sandbox Code Playgroud)

java multithreading process

5
推荐指数
1
解决办法
1422
查看次数

属性列表未在o:converter(Netbeans 7.3)中定义

我正试图org.omnifaces.converter.ListConverter在primefaces选项列表中使用new .我在maven的项目中添加了新的依赖项,并重建了项目以下载jar文件:

<dependency>
    <groupId>org.omnifaces</groupId>
    <artifactId>omnifaces</artifactId>
    <version>1.5</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我正在我的facelets中导入命名空间,如下所示:

xmlns:o="http://omnifaces.org/ui"
Run Code Online (Sandbox Code Playgroud)

不过,当我尝试<o:converter>在我的选项列表中使用时如下:

<o:converter converterId="omnifaces.ListConverter" list="#{projectBean.clientSource}" />
Run Code Online (Sandbox Code Playgroud)

我从netbeans 7.3收到一条消息说:

The attribute list is not defined in the component converter
Run Code Online (Sandbox Code Playgroud)

它似乎没有导致任何构建失败...我错过了什么?我是不是应该使用omnifaces?

configuration netbeans-7 omnifaces

5
推荐指数
1
解决办法
1156
查看次数

Java正则表达式从字符串中删除SQL注释

希望有人可以帮我解决这个问题!

我有一个看起来像这样的sql文件:

CREATE TABLE IF NOT EXISTS users(
    id INT UNSIGNED NOT NULL AUTO_INCREMENT,
    firstname VARCHAR(30) NOT NULL,
    lastname VARCHAR(30) NOT NULL,

    PRIMARY KEY (id),
    CONSTRAINT UNIQUE (firstname,lastname)
)
ENGINE=InnoDB
;

INSERT IGNORE INTO users (firstname,lastname) VALUES ('x','y');
/*
INSERT IGNORE INTO users (firstname,lastname) VALUES ('a','b');
*/
Run Code Online (Sandbox Code Playgroud)

我有一个web应用程序,它在启动时用这个函数初始化一个mysql数据库:

public static void initDatabase(ConnectionPool pool, File sqlFile){
    Connection con = null;
    Statement st = null;
    String mySb=null;
    try{
        con = pool.getConnection();
        mySb=IOUtils.copyToString(sqlFile);

        // We use ";" as a delimiter for each request …
Run Code Online (Sandbox Code Playgroud)

java regex sql

3
推荐指数
1
解决办法
4461
查看次数