public class BioHomework {
public static void main(String[] args) {
if(args.length < 2) {
throw new IllegalArgumentException("two args required");
}
String sequence = args[1];
if (!sequence.toLowerCase().matches("[atgc]{10,20}")){
throw new IllegalArgumentException("second arg should be 'atgc' string between 10 and 20 characters");
}
if ("u".equals(args[0])) {
System.out.println(sequence.toUpperCase());
} else if ("l".equals(args[0])) {
System.out.println(sequence.toLowerCase());
} else {
throw new IllegalArgumentException("first argument must be either 'u' or 'l'");
}
}
}
如何通过给出命令行参数让dna序列以大写和小写形式打印。以上代码只给我一条消息。
答案 0 :(得分:0)
只需更改RegEx即可接受大写或小写字符。从
[atgc]{10,20}
要
[aAtTgGcC]{10,20}