MCPcopy Create free account
hub / github.com/RealTimeGenomics/rtg-tools / getHeaderLines

Method getHeaderLines

src/main/java/com/rtg/vcf/VcfMerge.java:145–173  ·  view source on GitHub ↗
(CFlags flags)

Source from the content-addressed store, hash-verified

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 {

Callers 3

processMethod · 0.95
mainExecMethod · 0.95
mainExecMethod · 0.95

Calls 7

isMetaLineMethod · 0.95
createInputStreamMethod · 0.95
lengthMethod · 0.65
addMethod · 0.65
readLineMethod · 0.65
isSetMethod · 0.45
getValuesMethod · 0.45

Tested by

no test coverage detected