(CFlags flags)
| 143 | } |
| 144 | |
| 145 | static Collection<String> getHeaderLines(CFlags flags) throws IOException { |
| 146 | final List<String> extraHeaderLines = new ArrayList<>(); |
| 147 | if (flags.isSet(ADD_HEADER_FLAG)) { |
| 148 | for (final Object o : flags.getValues(ADD_HEADER_FLAG)) { |
| 149 | final String lineOrFile = (String) o; |
| 150 | if (lineOrFile.length() > 0) { |
| 151 | if (VcfHeader.isMetaLine(lineOrFile)) { |
| 152 | extraHeaderLines.add(lineOrFile); |
| 153 | } else if (new File(lineOrFile).exists()) { |
| 154 | try (BufferedReader r = new BufferedReader(new InputStreamReader(FileUtils.createInputStream(new File(lineOrFile), false)))) { |
| 155 | String line; |
| 156 | while ((line = r.readLine()) != null) { |
| 157 | if (line.length() > 0) { |
| 158 | if (VcfHeader.isMetaLine(line)) { |
| 159 | extraHeaderLines.add(line); |
| 160 | } else { |
| 161 | throw new VcfFormatException("In additional header file " + lineOrFile + ", line '" + line + "', doesn't look like a VCF header line"); |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | } else { |
| 167 | throw new VcfFormatException("Additional header argument '" + lineOrFile + "', doesn't look like a VCF header line or a file"); |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | return extraHeaderLines; |
| 173 | } |
| 174 | |
| 175 | @Override |
| 176 | protected int mainExec(final OutputStream out, final PrintStream err) throws IOException { |
no test coverage detected