/** * Chains <code>program</code> in front of the first "head" item in the list of * SAMProgramRecords in <code>header</code>. This method should not be used * when there are multiple chains of program groups in a header, only when * it can safely be assumed that there is only one chain. It correctly handles * the case where <code>program</code> has already been added to the header, so * it can be used whether creating a SAMProgramRecord with a constructor or when * calling SAMFileHeader.createProgramRecord(). */ public static void chainSAMProgramRecord(final SAMFileHeader header, final SAMProgramRecord program) { final List<SAMProgramRecord> pgs = header.getProgramRecords(); if (!pgs.isEmpty()) { final List<String> referencedIds = new ArrayList<>(); for (final SAMProgramRecord pg : pgs) { if (pg.getPreviousProgramGroupId() != null) { referencedIds.add(pg.getPreviousProgramGroupId()); } } for (final SAMProgramRecord pg : pgs) { // if record being chained has already been added, ignore it if (pg.getProgramGroupId().equals(program.getProgramGroupId())) { continue; } if (!referencedIds.contains(pg.getProgramGroupId())) { program.setPreviousProgramGroupId(pg.getProgramGroupId()); break; } } } }
/** * Chains <code>program</code> in front of the first "head" item in the list of * SAMProgramRecords in <code>header</code>. This method should not be used * when there are multiple chains of program groups in a header, only when * it can safely be assumed that there is only one chain. It correctly handles * the case where <code>program</code> has already been added to the header, so * it can be used whether creating a SAMProgramRecord with a constructor or when * calling SAMFileHeader.createProgramRecord(). */ public static void chainSAMProgramRecord(final SAMFileHeader header, final SAMProgramRecord program) { final List<SAMProgramRecord> pgs = header.getProgramRecords(); if (pgs.size() > 0) { final List<String> referencedIds = new ArrayList<String>(); for (final SAMProgramRecord pg : pgs) { if (pg.getPreviousProgramGroupId() != null) { referencedIds.add(pg.getPreviousProgramGroupId()); } } for (final SAMProgramRecord pg : pgs) { // if record being chained has already been added, ignore it if (pg.getProgramGroupId().equals(program.getProgramGroupId())) { continue; } if (!referencedIds.contains(pg.getProgramGroupId())) { program.setPreviousProgramGroupId(pg.getProgramGroupId()); break; } } } }
/** * Chains <code>program</code> in front of the first "head" item in the list of * SAMProgramRecords in <code>header</code>. This method should not be used * when there are multiple chains of program groups in a header, only when * it can safely be assumed that there is only one chain. It correctly handles * the case where <code>program</code> has already been added to the header, so * it can be used whether creating a SAMProgramRecord with a constructor or when * calling SAMFileHeader.createProgramRecord(). */ public static void chainSAMProgramRecord(final SAMFileHeader header, final SAMProgramRecord program) { final List<SAMProgramRecord> pgs = header.getProgramRecords(); if (!pgs.isEmpty()) { final List<String> referencedIds = new ArrayList<>(); for (final SAMProgramRecord pg : pgs) { if (pg.getPreviousProgramGroupId() != null) { referencedIds.add(pg.getPreviousProgramGroupId()); } } for (final SAMProgramRecord pg : pgs) { // if record being chained has already been added, ignore it if (pg.getProgramGroupId().equals(program.getProgramGroupId())) { continue; } if (!referencedIds.contains(pg.getProgramGroupId())) { program.setPreviousProgramGroupId(pg.getProgramGroupId()); break; } } } }
/** * Chains <code>program</code> in front of the first "head" item in the list of * SAMProgramRecords in <code>header</code>. This method should not be used * when there are multiple chains of program groups in a header, only when * it can safely be assumed that there is only one chain. It correctly handles * the case where <code>program</code> has already been added to the header, so * it can be used whether creating a SAMProgramRecord with a constructor or when * calling SAMFileHeader.createProgramRecord(). */ public static void chainSAMProgramRecord(final SAMFileHeader header, final SAMProgramRecord program) { final List<SAMProgramRecord> pgs = header.getProgramRecords(); if (!pgs.isEmpty()) { final List<String> referencedIds = new ArrayList<>(); for (final SAMProgramRecord pg : pgs) { if (pg.getPreviousProgramGroupId() != null) { referencedIds.add(pg.getPreviousProgramGroupId()); } } for (final SAMProgramRecord pg : pgs) { // if record being chained has already been added, ignore it if (pg.getProgramGroupId().equals(program.getProgramGroupId())) { continue; } if (!referencedIds.contains(pg.getProgramGroupId())) { program.setPreviousProgramGroupId(pg.getProgramGroupId()); break; } } } }
programRecord.setCommandLine(PROGRAM_GROUP_COMMAND_LINE); programRecord.setProgramName(PROGRAM_GROUP_NAME); programRecord.setPreviousProgramGroupId(existingId); outputHeader.addProgramRecord(programRecord);
programRecord.setCommandLine(PROGRAM_GROUP_COMMAND_LINE); programRecord.setProgramName(PROGRAM_GROUP_NAME); programRecord.setPreviousProgramGroupId(existingId); outputHeader.addProgramRecord(programRecord);
program.setPreviousProgramGroupId(PG.getPrevProgramId());
program.setPreviousProgramGroupId(PG.getPrevProgramId());