]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/toolkit/bamtools_convert.cpp
added reader.Open checks to a number of tools
[bamtools.git] / src / toolkit / bamtools_convert.cpp
index 86a3f9eeb7f6b27fe0af49b5b6356e52a025b2b5..730a061e62a407cc42b2834c2206179c458e4d30 100644 (file)
@@ -160,7 +160,10 @@ bool ConvertTool::ConvertToolPrivate::Run(void) {
     
     // open input files
     BamMultiReader reader;
-    reader.Open(m_settings->InputFiles);
+    if (!reader.Open(m_settings->InputFiles, false)) {
+        cerr << "Could not open input files" << endl;
+        return false;
+    }
     m_references = reader.GetReferenceData();
 
     // set region if specified
@@ -463,7 +466,10 @@ void ConvertTool::ConvertToolPrivate::PrintJson(const BamAlignment& a) {
                 case('H') : 
                     m_out << "\""; 
                     while (tagData[index]) {
-                        m_out << tagData[index];
+                        if (tagData[index] == '\"')
+                            m_out << "\\\""; // escape for json
+                        else
+                            m_out << tagData[index];
                         ++index;
                     }
                     m_out << "\"";