package hiseq; import shared.LineParserS4Reverse; import structures.ByteBuilder; /** * Uses a reverse parser because BGI headers have an unknown prefix. * As a result, it does not support comments, but this could be preprocessed. * @author Brian Bushnell * @date May 6, 2024 * */ public class BGIHeaderParser2 extends ReadHeaderParser { /*--------------------------------------------------------------*/ /*---------------- Main ----------------*/ /*--------------------------------------------------------------*/ public static void main(String[] args) { BGIHeaderParser2 ihp=new BGIHeaderParser2(); ihp.test(args.length>0 ? args[0] : null); ihp.parse(args[0]); System.err.println("toIllumina: "+ihp.toIllumina("ACGTACGT")); } /*--------------------------------------------------------------*/ /*---------------- Expected Format ----------------*/ /*--------------------------------------------------------------*/ //v300056266_run28L3C001R0010057888/1 //20A_V100002704L1C001R012000000/1 //E200008112L1C001R00100063962/1 //split: [v300056266, run28, 3, 001, 0010057888, 1] /*--------------------------------------------------------------*/ /*---------------- Public Methods ----------------*/ /*--------------------------------------------------------------*/ public BGIHeaderParser2 parse(String id_) { id=id_; extra=null; if(PARSE_EXTRA) {//Handles comments, but it's slow int idx=firstWhitespace(id); if(idx>=0) { extra=id.substring(idx+1); id=id.substring(0, idx); } } lp.set(id); return this; } private static int firstWhitespace(String s) { for(int i=0; i